↑ ↓ select, Enter open, Esc close

Test a command in the minimal cron environment

Adjust the values, the command updates live
user@server
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'

env -i clears all environment variables and sets only the few that cron provides on Debian, in particular PATH=/usr/bin:/bin and /bin/sh instead of bash. If the command fails here with command not found or missing variables, it will fail in the cron job too. The fix is to use absolute paths (/usr/local/bin/wp) or a PATH= line at the top of the crontab.

Note: The command is actually executed, so the risk is that of the command being tested.

Also searched as

  • cron job not working but works manually
  • script does not run under cron
  • test cron environment
  • command not found in cron job

Related one-liners

All in Cron

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.