Cron Service
From Wiki for Dragino Project
Dragino supports cron service which you can schedule your task to be executed periodically.
Steps to use cron service
- create file: /etc/crontabs/root
- modify /etc/crontabs/root for scheduling task, below is the format and example
#run script /root/test at 10 every hour #format [min] [hour] [day of month] [month] [day of week] [program to be run] 10 * * * * /bin/sh /root/test
- restart cron service
root@dragino-1a7f76:~# /etc/init.d/cron restart
Explaination of the time format
Variable Range:
Variable | Description |
---|---|
[min] | Minutes that program should be executed on. 0-59. Do not set as * or the program will be run once a minute. |
[hour] | Hour that program should be executed on. 0-23. * for every hour. |
[day of month] | Day of the month that process should be executed on. 1-31. * for every day. |
[month] | Month that program whould be executed on. 1-12 * for every month. |
[day of week] | Day of the week. 0-6 where Sunday = 0, Monday = 1, ...., Saturday = 6. * for every day of the week. |
[program] | Program to be executed. Include full path information. |
Use Operators:
Operator | Function |
---|---|
Asterisk (*) | Specifies all possible values for this field |
Comma (,) | Specifies a list of value for this field, for example, 1,5,6,8,10 |
Dash (-) | Specifies a range of value for this field, for example: 1-5 |
Slash(/) | Per , for example, */5, every 5 (minutes) |
Examples
- execute script at 8:30am every Monday To Friday
30 8 * * 1-5 /bin/test
- execute script every 5 minutes
*/5 * * * * /bin/test