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
/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"
  • 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

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.

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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