cron - Come configurare un crontab da eseguire in un momento specifico

original title: "cron - How to setup a crontab to execute at specific time"


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/

Come posso configurare il mio crontab per eseguire lo script X ogni giorno alle 23:59 senza inviarmi e-mail o creare log? In questo momento il mio crontab assomiglia a questo @daily /path/to/

Questo è il riepilogo dopo la traduzione, se è necessario visualizzare la traduzione completa, fare clic sull'icona "traduci"

Tutte le risposte
  • Translate

    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.

  • Translate

    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.

  • Translate

    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 ....