1

Can anyone please tell me about the following behaviour? I want to stop the batch tasks to be run in the background, so I stopped the cron using this command

$ sudo /etc/init.d/cron stop

And after this I can see the message

[ ok ] Stopping cron (via systemctl): cron.service.

I created one batch task to check whether this is working or not, but cron is still running every minute and processing the tasks.

Please tell me how do I stop cron to not process any task?

Thanks in advance.

1
  • 1
    Put a comment(#) before the cronjob and reload the cron service. – janasaiarun Dec 11 '17 at 12:21
1

Open the terminal and run

sudo service cron stop

And if it is not stopping the cron, you can backup the crontab and remove it's entry.

crontab -l > cron_backup.txt

crontab -r

Note that it will remove all crontab entries from machine. If you don't want to remove it and just want to disable it, adding a # in front of crontab entries would also do the job.

To restore the crontab

crontab cron_backup.txt

OR

You may use the pkill command to kill the cronjob by providing the process id.

You will get the process id from the following command.

ps -e | grep cron

Use the process id in the following command.

pkill <process id>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.