0

I have following cron jobs:

* * * * /usr/local/bin/email_redirect
* * * * /usr/local/bin/email_redirect

The python script is never ran and also nothing is written to syslog:

Nov 27 19:09:41 raspberrypi crontab[30824]: (pi) BEGIN EDIT (pi)
Nov 27 19:11:07 raspberrypi crontab[30824]: (pi) END EDIT (pi)
Nov 27 19:11:12 raspberrypi crontab[30837]: (pi) BEGIN EDIT (pi)
Nov 27 19:13:43 raspberrypi crontab[30837]: (pi) END EDIT (pi)

I am using crontab -e to edit the configuration. What am I doing wrong?

1
  • Is the cron daemon running? service cron status
    – fredden
    Commented Nov 27, 2016 at 19:41

3 Answers 3

2

You're missing one * in the cron line identification

The syntax should be, fun a user's cron

*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)
0

Cron needs to know how to execute the python script so you will need to add the path to the python executable and call the script.

Like so:

* * * * /path/to/python /usr/local/bin/email_redirect
0

It doesn't run kz you did not set the time to run.

The following will run the python script every one hour at 12:00am, 1:00am, 2:00am ...

0 * * * * /usr/local/bin/email_redirect 

This will run the script every day at 1:00pm

0 13 * * * /usr/local/bin/email_redirect

please find more here https://ole.michelsen.dk/blog/schedule-jobs-with-crontab-on-mac-osx.html

You must log in to answer this question.