In Linux-based systems, crontab is a well-known job scheduler. You can always use the cron daemon services if you need to conduct specific time-bound functions. What if your crontab stops operating at times? You may confuse yourself while finding out the reason behind this problem. In such a case, you will also try out all of the potential solutions. Please do not go for these options because, in this article, we will provide you some original methods for troubleshooting your crontab. So let’s start this journey!
Why is crontab not working in your system?
Crontab might fail for a variety of reasons:
- The first reason is that your cron daemon might not be working for any reason, resulting in your crontab failing.
- There also exists a possibility that your system’s environment variables are not settled correctly.
- Using your Crontab, the script you are trying to execute has some problems or is not executable or restricted.
- The script path you are trying to execute is not correct.
- Using crontab, you are trying to run a file and missing its extension.
There are several approaches for troubleshooting crontab in your system, depending upon the actual cause. We will demonstrate to you some of those methods in the upcoming sections.
Is the cron daemon running?
First of all, check out your cron daemon, and it’s working. For that, execute the below-given command and look for cron.
If the output shows you any number that refers to the cron’s main PID, it states that your cron daemon is working fine.
Otherwise, utilize the below-given commands for restarting the cron service.
$ sudo service cron start
$ sudo systemctl start cron
Now, check out the status of the cron service.
$ sudo systemctl status cron
Is cron running your cron job?
Now, have a look at the system log file of your system and check for cron errors.
$ grep CRON /var/log/syslog
This command will show you all the details related to the system log, including the crontab.
Raising the cron to debug level:
Another thing you can try out is to raise the cron to debug level. Open up the “/etc/rsyslog.d/50-default.conf”file.
$ nano /etc/rsyslog.d/50-default.conf
Comment out the following line in the opened configuration file.
Write out the below-given command to reload the logger.
$ sudo /etc/init.d/rsyslog restart
After reloading the logger, re-run the cron. Your crontab will work perfectly fine after following this procedure.
Crontab is a popular task scheduler included in the Linux system pack as it schedules a process to execute as root. Ever had an issue while running any job with crontab? If Yes, then Do not worry! This post will rescue you. We have provided different methods for troubleshooting crontab in your system.