On 12/15/19 6:22 AM, Rich Shepard wrote:
Yesterday I put this command in root's crontab:

# remove all files in /tmp not modified in 7 days daily at 1:20
20 1 * * * find /tmp -mtime +7 -type f -exec rm -f { } ';'

It is not working as I expected since there are files in /tmp as old as last
August. There are also old directories not modified for months.

First of all, directories won't be affected because you specified '-f', although I would expect files in those directories to be affected.

Second, what happens if you run it yourself (as root)? Try replacing the -exec ... with -print to make sure your test arguments are finding the files you expect.

Should I put this in a shell script and use 'test' first? Would the old
subdirectories removal be fixed by changing the rm option to -rf without
adversely affecting the results?

Regards,

Rich
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to