How to setup a crontab to execute at specific time
Question
How can I set up my crontab to execute X script at 11:59PM every day without emailing me or creating any logs?
Right now my crontab looks something like this
@daily /path/to/script.sh
Solution
When you do crontab -e, try this:
59 23 * * * /usr/sbin/myscript > /dev/null
That means: At 59 Minutes and 23 Hours on every day (*) on every month on every weekday, execute myscript.
See man crontab for some more info and examples.
OTHER TIPS
Following up on svrist's answer, depending on your shell, the 2>&1 should go after > /dev/null or you will still see the output from stderr.
The following will silence both stdout and stderr:
59 23 * * * /usr/sbin/myscript > /dev/null 2>&1
The following silences stdout, but stderr will still appear (via stdout):
59 23 * * * /usr/sbin/myscript 2>&1 > /dev/null
The Advanced Bash Scripting Guide's chapter on IO redirection is a good reference--search for 2>&1 to see a couple of examples.
You will with the above response receive email with any text written to stderr. Some people redirect that away too, and make sure that the script writes a log instead.
... 2>&1 ....