Jun 9, 2003 #1 snooperx Technical User Joined Jul 4, 2001 Messages 15 Location 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 Joined Apr 29, 2003 Messages 2,455 Location 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 Joined Jul 4, 2001 Messages 15 Location 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 Joined Jul 4, 2001 Messages 15 Location 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 Joined Mar 20, 2001 Messages 8,475 Location 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 Joined Jul 4, 2001 Messages 15 Location BR Allright, it worked great, thanks! [ ]s. Upvote 0 Downvote
Jun 12, 2003 #7 PHV MIS Joined Nov 8, 2002 Messages 53,708 Location 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.