Adds a cron job to run a command at specific interval etc.
SYNOPSIS
ee cron create [<site-name>] --command=<command> --schedule=<schedule> [--user=<user>]
OPTIONS
[<site-name>]
: Name of site to run cron on.
--command=<command>
: Command to schedule.
--schedule=<schedule>
: Time to schedule. Format is same as Linux cron.
[--user=<user>]
: User to execute command as. Not supported for host cron jobs. Default: www-data for site jobs.
Commands can’t contain ; or #. Use && or separate jobs.
A host job runs as root inside EasyEngine’s cron scheduler container, not on the server. It can’t run WP-CLI, PHP or Docker. Run WP-CLI commands as site jobs, and use the system crontab for scripts on the server.
We also have helper to easily specify scheduling format:
| Entry | Description | Equivalent To |
|---|---|---|
| @yearly (or @annually) | Run once a year, midnight, Jan. 1st | 0 0 1 1 * |
| @monthly | Run once a month, midnight, first of month | 0 0 1 * * |
| @weekly | Run once a week, midnight between Sat/Sun | 0 0 * * 0 |
| @daily (or @midnight) | Run once a day, midnight | 0 0 * * * |
| @hourly | Run once an hour, beginning of hour | 0 * * * * |
You may also schedule a job to execute at fixed intervals, starting at the time it’s added or cron is run. This is supported by following format:
- @every <duration>
Where duration can be combination of:
<number>h - hour
<number>m - minute
<number>s - second
So 1h10m2s is also a valid duration
EXAMPLES
# Adds a cron job on example.com every 10 minutes
$ ee cron create example.com --command='wp cron event run --due-now' --schedule='@every 10m'
# Adds a cron job on example.com every 1 minutes
$ ee cron create example.com --command='wp cron event run --due-now' --schedule='* * * * *'
# Adds a cron job on example.com every 1 minutes run as user www-data
$ ee cron create example.com --command='wp cron event run --due-now' --schedule='* * * * *' --user=www-data
# Adds a weekly WP-CLI job on example.com
$ ee cron create example.com --command='wp media regenerate --yes' --schedule='@weekly'
# Adds a cron job that runs in the cron scheduler container (host job)
$ ee cron create host --command='date' --schedule='@daily'
SUBCOMMANDS
| Name | Description |
|---|---|
| ee cron delete | Deletes a cron job |
| ee cron list | Lists scheduled cron jobs. |
| ee cron run-now | Runs a cron job |
| ee cron update | Updates a cron job. |
GLOBAL PARAMETERS
--sites_path=<path>
Absolute path to where all sites will be stored.
--locale=<locale>
Locale for WordPress.
--le-mail=<le-mail>
Mail-id to be used for letsencrypt.
--env=<env>
EasyEngine server environment.
--wp-mail=<wp-mail>
Default Mail-id to be used for WordPress site installation.
--sysctl=<true/false>
Whether to add sysctl config in docker-compose.
--skip-tty=<true/false>
Skip tty allocation for remote command execution.
--custom-compose=<custom-compose file>
Path to custom compose file.
--[no-]color
Whether to colorize the output.
--debug[=<group>]
Show all PHP errors; add verbosity to EE bootstrap.
--quiet
Suppress informational messages.