Test a command in the minimal cron environment
cron job not working but works manually | script does not run under cron | test cron environment | command not found in cron job | cron | env | troubleshootingenv -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