crontab not working on Centos Docker container
After a day wasted in suboptimal Googling and experimentation, the answer to this conundrum was commenting out the following line in the file /etc/pam.d/crond
(and then running service crond restart
):
session required pam_loginuid.so
This is because of some Docker-Centos security issue. I don't have further details on why this works. (Check this for details.)
Also, troubleshooting this made me realize a few gotchas which might be useful:
Check that you have crond running as a service (if not, use
/etc/init.d/crond start
)Each line in your crontab should be followed be a newline character
Your scripts and log file should have suitable write/executepermissions
crontab file shouldn't have weird Windows environment characters(like ^M)
In some rare cases, crond might have different time zone than yoursystem
Also check
/etc/cron.allow and /etc/cron.deny
files to verify whocan add/edit cron jobs
May your day be invested in more fruitful pursuits, stranger.