↑ ↓ select, Enter open, Esc close

#cron

12 one-liners with this tag.

All one-liners tagged cron

Check which scripts in cron.daily actually run

$run-parts --test /etc/cron.daily
harmlessCron

Delete a scheduled WP-Cron event

$wp cron event delete old_plugin_daily_event --path=/var/www/vhosts/example.com/httpdocs
cautionWP-CLI

Find out which cron job runs a command

#grep -rn "wp-cron.php" /etc/crontab /etc/cron.d /etc/cron.hourly /etc/cron.daily /etc/cron.weekly /etc/cron.monthly /var/spool/cron/crontabs 2>/dev/null
harmlessCron

List scheduled WP-Cron events

$wp cron event list --fields=hook,next_run_relative,recurrence --path=/var/www/vhosts/example.com/httpdocs
harmlessWP-CLI

Prevent overlapping cron jobs with flock

$flock -n /tmp/backup.lock /usr/local/bin/backup.sh
harmlessCron

Run a PHP script with a specific Plesk PHP version

$/opt/plesk/php/8.3/bin/php /var/www/vhosts/example.com/httpdocs/cron.php
cautionPHP

Run all scripts in cron.daily right now

#run-parts --verbose /etc/cron.daily
cautionCron

Run due WP-Cron events immediately

$wp cron event run --due-now --path=/var/www/vhosts/example.com/httpdocs
cautionWP-CLI

Show currently running cron jobs

$ps -eo pid,user,etime,cmd --forest | grep -A3 '[C]RON'
harmlessCron

Show system-wide cron jobs in /etc/crontab and /etc/cron.d

$grep -vE '^\s*(#|$)' /etc/crontab /etc/cron.d/*
harmlessCron

Show the cron log: when which job ran

#journalctl -u cron --since today --no-pager
harmlessCron

Test a command in the minimal cron environment

$env -i SHELL=/bin/sh PATH=/usr/bin:/bin HOME="$HOME" LOGNAME="$(id -un)" /bin/sh -c 'wp --path=/var/www/vhosts/example.com/httpdocs cron event run --due-now'
harmlessCron

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.