17 October 2025

Troubleshooting cron problems in cron.d files



Determining why a Linux cron job won't run can be maddeningly frustrating. Diagnostic information is spread across multiple logs including (depending on distribution):
/var/log/messages #look for cron specific messages
/var/log/secure #look for user authentication errors
/var/log/cron
Even after searching through the log files, problems can sometimes remain hidden.

Please note: a newer version of this article is available on Medium for free.


Background


There are two kinds of Linux crons. The first and most commonly known are user crontabs stored in
/var/spool/cron

edited and viewed with the commands:

crontab -e
crontab -l

The second cron type, file-based crons, are file scripts located in the /etc/cron.d directory in CentOS/RHEL distributions and others. We'll concentrate on the file-based variety here.

Solutions to Common Issues


Consider a cron file with the following contents:


#Run every day at 06:20 as user "username", recording stderr and stdout output to the my_script.log file
20 06 * * * username /home/username/my_script.sh > /home/username/my_script.log 2>&1
  • Make sure the user in the cron file does not have an expired or locked account
  • chage -l [username] #is user account or pw expired?

  • root user should not be expired
  • File permissions for cron file should match others and be owned by root, e.g. 644
  • cron file name cannot have dots; dashes and underscores are allowed
  • cron file must have an ending blank line!

No comments:

Post a Comment