Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

crontab question

Status
Not open for further replies.

gfunk123

IS-IT--Management
May 22, 2001
143
GB
I have a script that checks every 5 mins to see if a file exists and when it does finally appear it processes it. My question is , can i stop crontab writing an email to /var/mail everytime it doesnt find the file. The mailbox for the script runner has now got 22,000 items in there. I presume there is a switch or argument i can add to cron entry after the scriptname

any help would be greatly appreciated

regards
 
Redirect the script's output to /dev/null:

0 0 * * * /home/jdeckard/bin/some_script > /dev/null 2>&1
 
gfunk123
A cron job sends only errorsto the mailbox. So, if yo mailbox id filling up, then yo cron job may be generating errors mate.

Redirect output and error to separate files and check them after cron job is executed.

something like...

10 10 * * * $HOME/somescript.sh > $HOME/somescript.log 2> $HOME/somescript.err

Hope this helps ya.
 
As an addendum to the above post,
if yo cron job is generating errors/output that you can safely ignore, then you can change the redirection of output and errors to /dev/null .

When setting up a cron job, it is good practice to redirect output and errors to different files. Ideally these files should be empty after the cron job is executed. When you're satisfied with your cron job, you can then redirect output and errors to /dev/null.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top