Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a process which moves files from our EC2 server to s3, we're not sure why but it stores them in /tmp whilst moving them, but for some reason it also leaves them there once the process has completed.

This would be fine if tmpwatch deleted them, but it doesn't. They go into a folder called mixtape2 so the location is /tmp/mixtape2 here is my tmpwatch now, could someone help as to what I need to add change to make this happen to files a day old? (or if its possible to delete them from /tmp as soon as they are moved)

#! /bin/sh
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
-X '/tmp/hsperfdata_*' -a -f 1d /tmp
/usr/sbin/tmpwatch "$flags" 1d /var/tmp
/usr/sbin/tmpwatch "$flags" -a -f 1d /tmp/mixtape2
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
if [ -d "$d" ]; then
/usr/sbin/tmpwatch "$flags" -f 1d "$d"
fi
done
share|improve this question
    
How are those files being created, and what is moving them? If you want to fix the problem at the source you need to provide details about the root of the problem. As for tmpwatch, it looks like it should be working. –  Zoredache Apr 11 '13 at 23:15
    
what is the user trying to delete the files and which user owns the files. try to run "ls -la /tmp/mixtape2" so you can get a full printout of what is going on. –  WojonsTech Apr 12 '13 at 1:27
    
@WojonsTech They belong to root - does that mean tmpwatch cant delete them? total 76 drwxr-xr-x 2 root root 4096 Apr 10 11:07 . drwxrwxrwt. 4 root root 69632 Apr 12 03:46 .. –  Danny Shepherd Apr 12 '13 at 10:02

1 Answer 1

up vote 0 down vote accepted

If you have files owned by root user and root group and the user trying to delete them is not in that group or the root user then your permissions have to be set to allow deletes.

So you seem to have one folder that is

drwxr-xr-x this means anyone can enter the folder but only root can delete or add things to the folder its self.

drwxrwxrwt this means anyone can delete or add something to the folder

If you have files in a folder then tmpwatch wont delete the folder So make sure the permissions of the files in that folder can be modifyed by that user.

share|improve this answer
    
How would I go about fixing this then? Tmpwatch runs as a cron job so I presumed it would be running as root? Or does it run as system which is not as powerful as root? Is there a single fix I can do to make the folder content deletable by tmpwatch in the future? –  Danny Shepherd Apr 13 '13 at 9:49
    
when you do, crontab -e are you logged in as a user or as the root user? –  WojonsTech Apr 13 '13 at 19:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.