↑ ↓ select, Enter open, Esc close

Cron

Create, check and debug cron jobs. With the usual pitfalls such as a missing PATH and swallowed output. The Cron Generator in the tools section helps as well.

11 one-liners: 9 harmless, 2 caution, 0 destructive

All Cron one-liners

Add a cron job that logs its output

$(crontab -l 2>/dev/null; echo "*/15 * * * * /usr/bin/php /var/www/vhosts/example.com/httpdocs/wp-cron.php >> /var/www/vhosts/example.com/logs/wp-cron.log 2>&1") | crontab -
caution

Back up the crontab to a dated file

$crontab -l > ~/crontab-backup-$(date +%F).txt
harmless

Check which scripts in cron.daily actually run

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

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
harmless

Prevent overlapping cron jobs with flock

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

Run all scripts in cron.daily right now

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

For the websites on your server

Free SEO and PageSpeed check

GENLOC.SEO analyzes any domain for load time, Core Web Vitals and on-page issues and tells you in plain words what is going on. Available in 11 languages.

by GENLOC.NETWORK, the team behind myline.de

Show currently running cron jobs

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

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

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

Show the cron log: when which job ran

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

Show the crontabs of all users at once

#for u in $(cut -d: -f1 /etc/passwd); do crontab -l -u "$u" 2>/dev/null | grep -vE '^(#|$)' | sed "s/^/$u: /"; done
harmless

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'
harmless

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.