Does anyone have a script that will remove old files?
I want to go thru various directories and remove files older than 1 day.
ALSO - Anyone know of any good Shell script freeware sights ?
using the find command take a look at the mtime/ctime parameters which allow files older or newer that a certain number of days to be located. Then use the exec parameter to remove the required files.
Hello, you can use
[tt]
find /starting/direc -newer reference_file -exec rm {} \;
[/tt]
or
[tt]
find /starting/direc -mtime +number -exec rm {} \;
[/tt]
The first form compares the files with your reference file and then executes a rm in the files newer than... you can use [tt]-n -newer file[/tt] to remove files older than your reference. Or you can use [tt]-ok[/tt] instead of [tt]-exec[/tt] to receive a propmt for every and each file found.
The second form selects files with a modification time greater than the number of days selected (+number)...
Try the command skulker ---it cleans up filesystems and remove unwanted files. Candidate files include: those in /tmp directory;files older than a certain age ;a.out file;core files. Skulker is normally invoked daily by the cron command as part of the root's crontab file.
You can modify the skulker shell scripts to suit local need for the removal of files.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.