Jun 9, 2003 #1 snooperx Technical User Jul 4, 2001 15 BR Hello all! I´m wondering if someone could provide a script that would sweep files off the /tmp dir only when they´re older than 30 days! Thanks for any help. Jeffo.
Hello all! I´m wondering if someone could provide a script that would sweep files off the /tmp dir only when they´re older than 30 days! Thanks for any help. Jeffo.
Jun 9, 2003 #2 Salem Programmer Apr 29, 2003 2,455 GB To check it works, by printing out what it finds Code: find /tmp -mtime -30 -print To actually delete stuff Code: find /tmp -mtime -30 -exec rm -f {} \; Upvote 0 Downvote
To check it works, by printing out what it finds Code: find /tmp -mtime -30 -print To actually delete stuff Code: find /tmp -mtime -30 -exec rm -f {} \;
Jun 9, 2003 Thread starter #3 snooperx Technical User Jul 4, 2001 15 BR Allright Salem. Thanks for the hints. I'll try it out tomorrow. I'll be using this on an AIX and HP-UX machines if it works. [ ]s! Jeffo. Upvote 0 Downvote
Allright Salem. Thanks for the hints. I'll try it out tomorrow. I'll be using this on an AIX and HP-UX machines if it works. [ ]s! Jeffo.
Jun 10, 2003 Thread starter #4 snooperx Technical User Jul 4, 2001 15 BR Uh-oh...seems that the first command is listing ALL files on /tmp, even those that I just touched.... Any hints?? Upvote 0 Downvote
Uh-oh...seems that the first command is listing ALL files on /tmp, even those that I just touched.... Any hints??
Jun 10, 2003 #5 KenCunningham Technical User Mar 20, 2001 8,475 GB Jeffo, the -mtime -30 should be -mtime +30 to give you files over 30 days old. Just a typo, I think. HTH. Upvote 0 Downvote
Jeffo, the -mtime -30 should be -mtime +30 to give you files over 30 days old. Just a typo, I think. HTH.
Jun 11, 2003 Thread starter #6 snooperx Technical User Jul 4, 2001 15 BR Allright, it worked great, thanks! [ ]s. Upvote 0 Downvote
Jun 12, 2003 #7 PHV MIS Nov 8, 2002 53,708 FR If you have a lot of old files, this can run faster: Code: find /tmp -mtime +30 -print | xargs rm -f Hope This Help PH. Upvote 0 Downvote
If you have a lot of old files, this can run faster: Code: find /tmp -mtime +30 -print | xargs rm -f Hope This Help PH.