A puzzle! Crontab and mkdir and files, oh my!

Ralf Mardorf kde.lists at yahoo.com
Thu Apr 24 12:08:51 UTC 2025


PS:

$ tldr find

[snip]

  - Run a command for each file (use `{}` within the command to access the filename):
    find root_path -name '*.ext' -exec wc -l {} \;

  - Find all files modified today and pass the results to a single command as arguments:
    find root_path -daystart -mtime -1 -exec tar -cvf archive.tar {} \+

[snip]

Correction it should probably read

0 1 * * * username find /home/ubuntu/data -type d -name '*_temp*' -exec rm -r {} \+ > /home/ubuntu/data/log/adfd_cleanup.log 2>&1

for running

rm -r foo_temp-1 bar__temp-x ...

if so ">" is correct, a good idea to always overwrite the log file when the crone job runs again,

or, but less likely

0 1 * * * username find /home/ubuntu/data -type d -name '*_temp*' -exec rm -r {} \ >> /home/ubuntu/data/log/adfd_cleanup.log 2>&1

for running

rm -r foo_temp-1; rm bar__temp-x; ...

this requires ">>" to get all the output and next time the crone job runs it keeps the old log entries.





More information about the ubuntu-users mailing list