Cron Job Delete Log Files

Some observations: • The fifth column of a crontab entry has a range of 0 (Sunday) to 6 (Saturday), not 1-7. • Environment settings in a cron job are pretty sparse and tasks will often behave differently than they would in your interactive shell. It's a long shot, but make sure that the rm command is in the $PATH variable. • Debugging cron jobs is tricky. Sometimes output from a job that isn't redirected to a file is mailed to you. Eric Singer Project.

Sign up or log in to customize your list. Auto delete files older than 7 days. Browse other questions tagged files cron delete automation or ask your own. Feb 29, 2012 Setting a cron job to delete log files. Discussion in 'General Discussion' started by ESelf2, Feb 27, 2012.

Sometimes it isn't. Exercise more control over the output of your jobs: * * * * * my_cron_job >>/home/me/cron_job.log 2 >>/home/me/cron_job.err • Try something simple to make sure cron is working and working the way you expect it to. Something like: * * * * * /usr/bin/date >>/home/me/cron.test 2>&1 will test the basic functionality.

Cron Job Delete Log Files

You can make it more complicated from there. Mobrule's answers are a good troubleshooting guide. Additional hints: • If you don't get any mail, the system is probably not completely configured: All cron implementations (that I know of) will mail output (stdout & stderr) to the user who created the crontab (some also support a variable MAILTO to set that user). Problems usually occur if local mail delivery isn't correctly configured fot the user.

If you use cron, always make sure local mail delivery is set up. Most Linux distros will do that automatically is you install their default mail server, which will dump mail into /var/spool/mail/, or forward it to the address given in the file.forward in the users' $HOME. This should be fixed if you're using cron, otherwise error messages will get discarded. • If you can only use Plesk, some of the settings mentioned above may not be accessible to you (though they should have been set by the hosting provider). In that case redirecting stdout & stderr to a file is a good workaround, as in mobrule's answer.