cron job not working : troubleshooting steps

In this post,I am sharing the troubleshooting steps for cron job problem. You may have seen many times, the cron job stopped working suddenly or not working on first instance. As a Linux System Engineer,I also faced this problem many times.The reasons are many and we are sharing few them which generally occurs.

What is Cron

Cron is a utility in Unix Like Operating System,which is a time based job scheduler. To maintain the Cron, we use the cron table called crontab .
Here,the job means the script/command . When we define any job(script/command/process) in crontab to be excecuted ,that job is called cron job.

Cron is different from at scheduler. The one basic different is at can be used for only one time. Whereas in Cron, the job is executed every time as per the defined date,day,time and month.

Crontab Syntax :

m h dom mon dow command

Here in above syntax,
m = Minute
h = Hour
dom = Date of month
dow = Day of week (eg. Sunday,Monday,Tuesday etc.)
Command = The command or script to be run from cronjob.

Recommendation : Read edit the crontab without using crontab -e. It will give some insight on how crontab can be edited from file.

Troubleshooting Steps for cronjob

We are listing some common practices for troubleshooting cronjobs. We expect you have some knowledge about setting cronjob.

1. Command / Script not executed from cronjob

This is the common problem generally seen by many Linux system admins. Here are the possible reason

(a) Command not found : Command is not available in system which system admin want to execute. Check the command if it is available in system. If not, then install the command/utility on your system.

(b)In this same section, we will talk about script do not run from cronjob. The possible reason for script not running are –
* Execute permission is not given to script for the user.
* Appropriate Ownership and group is not given to script.
* Command used in script is not available in system.
* Typo error in script.

2. Password expires

It might be possible the password is expire for user who will run the cronjob. For troubleshooting, check password expiration for root and other users.
To check password expiration status, use the below given syntax. Replace username with your system user.

chage -l username

3. User account is inactive

The inactive user account is another reason for cronjob suddenly stop working or do not work.
You can use similar command as we have used for checking password expiration.

chage -l username

4. Disk usage or inode is 100% full

When disk is full with no free space, it will not allow script or command to be run.
It might be possible when inode is 100% for partition, script or command will not run from cronjob.

To check disk space and inode usage togetherly, use the following command.

df -thi

There can also be possible reason which vary from network to network and type of servers.

1 thought on “cron job not working : troubleshooting steps”

  1. When i tried to edit the cronjob,getting this error
    # crontab -e
    crontab: installing new crontab
    crontab: error renaming /var/spool/cron/#tmp.XXXXkLwcMZ to /var/spool/cron/root
    rename: Is a directory
    crontab: edits left in /tmp/crontab.1zNzz2

    ##cron entries which i tried to enter
    00 22 * * * /apps/LDAP_Daily_Backup/Script/Backup_LDAP.sh

Comments are closed.