Monday, October 22, 2012

Search & Delete the logs + cron

Delete from a path
sudo find /Path-to-directory/ -name *.log  -exec rm -rf -v {} \;

Delete from the current directory
sudo find . -type f -name "*.bak" -exec rm -rf -v {} \;

By default cron jobs sends a email to the user account executing the cronjob. If this is not needed put the following command At the end of the cron job line .
>/dev/null 2>&1

To collect the cron execution execution log in a file :
30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log

No comments:

Post a Comment