Cron job is not running
Work out whether WordPress cron or an Avaloi cron job is late or failing, read the cron log and the last error line, and fix the schedule or the command.
Avaloi runs cron on the server. WordPress cron (scheduled posts, plugin tasks, WooCommerce actions) and your own cron jobs both run from the server's cron service, never on page loads. The Cron tab (under Tools) shows both, and the cron.log on the Logs tab holds every run.
What you see
- A job's status says Last run failed, Missed a run, or Not allowed, or the row shows no run at all.
- The WordPress cron card says Failing or Not running.
- Scheduled posts, reminder emails, or plugin tasks in WordPress happen late or not at all.
- Add cron job refuses the schedule or the command you typed.
- The bell shows a notice that a cron job failed, did not run, or is not allowed.
Check these first
- Decide which cron you mean. WordPress tasks run through WordPress cron, which the server starts every 15 minutes on live, so a task can start up to 15 minutes after its time. Staging and multidev environments have WordPress cron off until you add a job there that runs
cron event run --due-now. For a tighter schedule on live, add a job with that command, for example every 5 minutes. It replaces the built-in 15 minute run. - Read the status and the line under it. A Last run failed row shows the last error line of the output. Missed a run names the time the run was due. Not allowed says why the command is refused.
- Open the cron log. Open Logs and choose
cron.log. Each run has a line with its exit code and duration. Search for the job's id orskipped. A line that saysskipped, the previous run is still goingmeans the job takes longer than its schedule: use a slower schedule. A line that saysstopped after ... the run took too longmeans the job ran past its limit (1 hour, or 10 minutes for the built-in run). - Check the pause switch. A paused job never runs until you turn it back on. Pause and resume from the switch or the row's menu, or call
PATCH /v1/environments/{id}/cron/{cron_id}. - Open the last run. Open the row to see the exit code, the full output, and when Avaloi removes it. An exit code other than zero means the command failed, and the output says why. Avaloi keeps the output for 7 days. If there is no run to show, the job has not run in the last 7 days, or never has.
- Check the schedule. A job runs at most once every 5 minutes, and may start up to 45 seconds late. Times use UTC. A job set to run on one day of the month looks idle for weeks.
- Check the environment. Each environment has its own cron jobs. Use the environment switcher at the top of the site to make sure you are looking at live and not staging, or the other way round. Jobs on live are not copied to staging.
- Read error.log and php-error.log. A PHP fatal error from a plugin that a command loads shows there, even when the cron output is short.
Fix it
- If the job is paused, turn the switch on.
- If the exit code is not zero, fix the command. Run it under Tools, WP-CLI, without the
wpprefix, to see the result right away. The same allowlist applies in both places, so a command refused there is refused in cron too. - If the status is Not allowed, edit the job to an allowed WP-CLI command. Jobs made before Avaloi limited cron to WP-CLI commands (for example a
phpscript or a shell line) stay in the list but never run. Pause or delete them, or replace the command. - If the schedule was refused, pick every 5 minutes or slower in the schedule builder, or correct the cron expression.
- If the job is on the wrong environment, add it again on the right one and delete the old one. Deleting asks you to type the job's description.
- If WordPress cron is more than 15 minutes late on live, check for a paused cron job that runs
cron event run: it replaces the built-in run, so turn it on or delete it. - If the WordPress cron card says Not running, Avaloi has noticed and repairs it on its own. It writes the cron files to the site's server again, and starts the cron service if it stopped. If the card still says Not running after about 20 minutes, support has been told. Write to [email protected] with the site name and the environment.
Still stuck
Write to [email protected] with the site name, the environment, the request ID from the API response or the job ID, and what you tried. Add the cron job's description, its schedule, the exit code and output of the last run, and the lines of cron.log around the time you expected the run.
Related
Still stuck?
Email [email protected] with your site name and what you tried, or send us a message.