Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I stop a cron job which is currently running?

share|improve this question

migrated from stackoverflow.com Jan 12 '11 at 7:29

This question came from our site for professional and enthusiast programmers.

1  
The three answers below interpret this question in three ways. @GURU, could you please clarify what you would like to do? Would you like to kill a process started by cron that is now running, or would you like to prevent the job running in the future? –  jcrawfordor Jul 29 '11 at 3:51

6 Answers 6

You can do this the same way you'd stop any process.

To stop a currently running cron job, you can do one of the following:

pkill process-name

or if you know the PID (you can determine it by running ps):

kill 1234

(substituting the actual PID)

share|improve this answer

To stop running cron job .First get the process id of your command with

top -p $(pgrep -d',' your_command)

eg:-

top -p $(pgrep -d',' httpd)

and run

kill PID replace PID with process id

share|improve this answer

If you are using Redhat (RHEL)/Fedora Core/Cent OS Linux use the following command :

/etc/init.d/crond stop

If you are using Debian or Ubuntu Linux the following command :

/etc/init.d/cron stop

P.S : You should be root to do these things

share|improve this answer
    
i think it stops all crons .to stop particular cron may i know the command –  GURU KUMAR Jan 12 '11 at 7:24
    
can u pls suggest any command sen –  GURU KUMAR Jan 12 '11 at 7:27
    
I dont think it is possible in a straight way.. Maybe we should go for a hack. –  Sen Jan 12 '11 at 7:29

You can edit the cron table and comment out the task in question. Switch to the user that controls the task, export your editor of choice into the environment, then use crontab -l:

$ su - root
...
# EDITOR=vi; export EDITOR
# crontab -l
share|improve this answer
    
That lists the crontab. Use crontab -e to edit it. For systems that have it, it's preferable to use sudo instead of su. Also, crontab -e would work for the user (or root) crontab, but not the system crontab (e.g. /etc/cron*). –  Dennis Williamson Jan 12 '11 at 11:40

First type ps aux to see what all processes are running.

Then note down the PID of each process you want to stop

Then type

kill {PID} for each process.

Also do have a look at these links (superuser links) :

Verify-that-a-cron-job-has-completed

ps-aux-output-meaning

share|improve this answer

Strange, no one has mentioned this method:

$ crontab -e

In the opened editor, delete line of the task you want to stop or insert a # sign, save and exit

e.g.

before

* * * * * some_script1
* * * * * some_script2

after

* * * * * some_script1
#* * * * * some_script2

or

* * * * * some_script1
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.