MIN HOUR DOM MON DOW CMD
Schedule a job for more than one instance (e.g. twice a day)
Below example executes the specified script (send_reports.rb) at 10:00 and 16:00 on every day. The comma separated value in a field specifies that the command needs to be executed in all the mentioned time.00 10,16 * * * ruby /home/luke/scripts/send_reports.rb
10,16 – 10 AM and 4 PM
* – Every day
* – Every month
* – Every day of the week
Schedule a job for specific range of time (e.g. only on weekdays)
To schedule a job to be ran for every hour with in a specific range of time then use the following. This example checks the status of the server everyday (including weekends) during the working hours 10 a.m – 3 p.m00 10-15 * * * ruby /home/luke/scripts/check-server-status.rb
10-15 – 10 am,11 am, 12 am, 1 pm, 2 pm, 3 pm
* – Every day
* – Every month
* – Every day of the week
Execute a job every 5 minutes
*/5 * * * * /home/luke/scripts/do_work.sh
Execute a job every 5 hours
0 */5 * * * /home/luke/scripts/backup.sh
Keyword Equivalent
@yearly 0 0 1 1 *
@daily 0 0 * * *
@hourly 0 * * * *
@reboot Run at startup.
Schedule a job for first minute of every year using @yearly
When you want a job to be executed on the first minute of every year, then you can use the @yearly cron keyword in way shown below.@yearly /home/luke/scripts/sell-db-annual-maintenance
Schedule a background job every day using @daily
Use the @daily cron keyword to do a daily backup file using backup-invoices shell script at 00:00 on every day.@daily /home/luke/scripts/backup-invoices "day started"
Brak komentarzy:
Prześlij komentarz