How to Start, Stop and Restart Cron Jobs
Troubleshooting cron related issues? Starting and stopping cron jobs could help. Here's how to do that.
— Team LHB
Cron jobs are an excellent way of automating tasks at a predefined time in Linux. From continued backups to system resource usage, it can do many things that make the life of a Linux sysadmin easier.
At times, you'll notice that cron jobs didn't run as expected. Checking the cron logs is the first step of troubleshooting.
Stopping, starting, or restarting the cronjobs is part of the troubleshooting process.
In this quick tutorial, I'll share how to stop, start or restart cron services in Linux.
How to start cron job
If the cron daemon is not started in the Linux system, the cron job will not execute. You have to start the cron service first.
Like most other things in Linux, the way of handling services is also different. This is why I am listing different commands for Debian and Red Hat systems.
service crond start
On older versions of Redhat and Centos, use:
For Ubuntu and Debian Systems:
sudo service cron start
On older versions, you can use the following:
sudo /etc/init.d/cron start
You won't see anything in the output if the commands run successfully. How do you know if cron job is running then? Check the status of the cron service with the following:
sudo service cron status
It should show the active status:
That takes care of starting cron services. Let's see about stopping it.
How to stop cron job
If you don't want to keep on running cron jobs, stop it until your troubleshooting is over. You can start it again after that.
On Redhat and CentOS, use the command below to stop the cron service:
service crond stop
For older versions, use:
For Ubuntu and Debian, you can use this command:
sudo service cron stop
or use the below command for older versions:
sudo /etc/init.d/cron stop
You can check if the cron service is stopped or not using the command:
sudo service cron status
It should show an inactive state:
How to restart the cron job
Did you try turning it off and on again? Jokes apart, restarting often fixes things on its own. While troubleshooting, you may try restarting the cron service as well.
On Redhat and CentOS
service crond restart
Or try the older commands:
For Ubuntu and Debian systems, use
sudo service cron restart
The older command can also be tried.
sudo /etc/init.d/cron restart
Restart is equivalent to stopping and starting the service again. You can try that as well.
I hope you will have got a good understanding of the cron jobs and how to start, stop, and restart them.
If you are new to Cron, you can refer to our beginner's guide to cron.