Linux – Ubuntu cron job every workday

cronlinuxscheduled-taskUbuntuubuntu-16.04

On Ubuntu 16, I'm trying to trigger cron job at 8:00 AM on workdays, and here is what I've tried so far

0 8 * * 1-5 /path/to/command

and

0 8 * * MON-FRI /path/to/command

Does not work

Best Answer

These syntaxes are valid for all working days a 8:00 AM :

  • 0 8 * * 1-5 /path/to/command >/dev/null 2>&1
  • 0 8 * * 1,2,3,4,5 /path/to/command >/dev/null 2>&1 as you said @aleksandar-pavić

More explanations with these links :

The use of >/dev/null 2>&1 is optional, the goal is to redirect all the outputs to /dev/null.

You must have another problem, you must also specify the user if you use crontab -e

Here is a reminder of the cron syntax

* * * * * *
| | | | | | 
| | | | | +-- Year              (range: 1900-3000)
| | | | +---- Day of the Week   (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month  (range: 1-31)
| +---------- Hour              (range: 0-23)
+------------ Minute            (range: 0-59)
Related Topic