ScottSwezey.com

Webmaster, Software dev, Business owner, Y2K Survivor,  User

Mysterious problem with cPanel cron jobs not working (Solved)

We recently ran into a strange situation where cron jobs configured within cPanel didn’t work. They wouldn’t send email. They wouldn’t run scripts. They didn’t do anything. Yet all of the typical troubleshooting turned up nothing: Permissions were correct. The scripts ran fine from CLI. Shell access was enabled for the account. Output wasn’t being directed to /dev/null. Everything was configured right. etc.

It turns out that cron settings are stored (on CentOS6, at least) under /var/spool/cron/$USER. In this file, you can find the email address that should get cron output, the various cron lines, and most interestingly, a setting for the shell to use for that users cron jobs.

In this case, it was set for

SHELL="/bin/false"

Which meant that scripts that worked just fine from CLI, didn’t work at all from cron.


The solution

Correct settings, depending on your setup, seem to be:

SHELL="/usr/local/cpanel/bin/jailshell"

or

SHELL="/bin/bash"

After a quick service crond restart to be safe, everything was instantly back to normal. I’m not even sure restarting crond was needed.

You can't comment here, but I am active on Twitter. Just mention @ScottSwezey to get in touch.