Linux‎ > ‎QNAP NAS‎ > ‎

QNAP: add cron job

1] Edit /etc/config/crontab file and add your custom job to the scheduler.

Syntax of crontab (field description)

The syntax is:

 
1 2 3 4 5 /path/to/command arg1 arg2
 

OR

 
1 2 3 4 5 /root/backup.sh
 

Where,

  • 1: Minute (0-59)
  • 2: Hours (0-23)
  • 3: Day (0-31)
  • 4: Month (0-12 [12 == December])
  • 5: Day of the week(0-7 [7 or 0 == sunday])
  • /path/to/command - Script or command name to schedule

Easy to remember format:

* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

2] Run crontab /etc/config/crontab to make cron aware of changes to crontab file.

3] Restart cron – /etc/init.d/crond.sh restart

4] Check the new crontab by using crontab -l or by cat /etc/config/crontab

Comments