brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wp cron event run --due-now runs the stuck scheduled tasks

Cron
~/tips/tip-wordpress-cron-event-run-due-now

wp cron event run --due-now

Runs every overdue WordPress scheduled task immediately instead of waiting for the next visitor.

Scheduled posts that miss their time are a classic WordPress annoyance. You can poke the scheduler by hand.

WP-Cron does not run on a clock. It runs when somebody visits the site. A quiet site means late jobs, and that is where missed schedules and stale backups come from. WP-CLI can run whatever is overdue, right now.

wp cron event list
wp cron event run --due-now

The first command shows what is scheduled and when it is next due. The second executes everything that is due and prints each hook with its timing, plus a total. If a scheduled post was stuck on “Missed schedule”, this is the quickest nudge.

The docs say the command respects the doing_cron transient, which stops overlapping runs. So it will not trample a job that is already in progress.

The caveat is that this is a manual fix. If your jobs are late all the time, fix the cause instead, which usually means running the scheduler from a real cron job. Also keep in mind that a due job runs for real: if it sends emails, those emails go out.

Further reading: wp cron event run (WP-CLI command reference), On this site: switch off WP-Cron and let a real cron job do the work, On this site: systemctl list-timers is cron's answer inside systemd

Going deeper: Guide: find out why a Linux service failed, with journalctl

More Cron tips echo 'systemctl restart myapp' | at 03:00 tomorrow 55 23 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && /usr/local/bin/month-end.sh EDITOR=nano crontab -e 30 6 * * mon /usr/local/bin/weekly-report.sh @daily /usr/local/bin/backup.sh All Cron tips (32) All topics

Link