Cron Configuration Reference
This article is a Stub. You can help the Sympl Project by expanding it.
Each domain in Sympl can have it's own crontab to run specific tasks. This is configured the same as the normal system crontab, and is kept in /srv/example.com/config/crontab
in order to keep tasks associated with domains.
Scheduling Tasks
The Sympl crontab works similarly to the normal system crontab, however the only environment variables which can be set are PATH
and MAILTO
.
Each line starts with five values which specify when the job should be run, followed by the command to run, separated by whitespace. Comments begin with a hash (#
) and must be on a line by themselves.
minute hour day month day_of_week command_to_run
Field | Allowed values |
---|---|
minute
|
* 0 -59 , - /
|
hour
|
* 0 -23 , - /
|
day
|
* 1 -31 , -
|
month
|
* 1 -12 or JAN -DEC , -
|
day_of_week
|
* 0 -6 or SUN -SAT , -
|
Commas (,
) are used to separate items in lists, and hyphens (-
) are ranges.
The slash (/
) is preceded by an asterisk (*
) and followed by a number which indicates the job should run if the minute or hour is divisible by the number, for example a minuite
value of */5
will run the task every 5
minutes.
Time Shortcuts
There are a number of shortcuts for common times for tasks to run, which replaces the five values above.
@shortcut command_to_run
Shortcut | Tasks will Run |
---|---|
@hourly
|
Every hour on the hour. |
@daily or @midnight
|
Every day at midnight. |
@weekly
|
Once a week on Sunday. |
@monthly
|
Each month on the 1st at midnight. |
@yearly or @annually
|
Midnight at Jan 1st each year |
Note that there is no @reboot
entry supported. If you need a task to run after a reboot, you will need to add it in a system crontab.
Example Configuration
# Send any output to webmaster@example.com MAILTO=webmaster@example.com # Run /srv/example.com/synchronise_orders.sh every 10 minutes. */10 * * * * /srv/example.com/synchronise_orders.sh # Run /srv/example.com/mail_overnight_orders.sh at 9:00 on a Monday to Friday. 0 9 * * MON-FRI /srv/example.com/mail_overnight_orders.sh # Run /srv/example.com/generate_stats.sh every day at midnight. @daily /srv/example.com/generate_stats.sh # Write the text "Happy New Year!" every year. @yearly echo "Happy New Year!"
Testing Configuration
Sympl includes a parser which allows you to check the next run-time of the tasks. Run sympl-crontab --test /srv/example.com/config/crontab
to get a list of the configured tasks, and their next run-time.
Configuration Reference
File or Directory | Used For | More |
---|
See also Configuration Reference for other configuration files.