1753354 Members
5059 Online
108792 Solutions
New Discussion юеВ

Re: Cron does not stop

 
Mukul_Upadhyaya
Advisor

Cron does not stop

Folks,
I need to stop the cron job fro applying application patches. Every time I try to stop the cron using "/sbin/init.d/cron stop", the cron daemon does not stop!
Is it b'coz that at that point in time there are child processes owned by cron that the daemon is waiting to complete before shutting itself down ?
To overcome this situation I implmented a ksh function that first attempts a graceful shutdown of cron daemon (/sbin/init.d/cron stop). If cron daemon is still found to be running then function sends kill -9 on the PID of the cron daemon. Are there any negative outcomes of this approach ?
5 REPLIES 5
RAC_1
Honored Contributor

Re: Cron does not stop

The startup script clearly says that it shouldnot be stopped. But you can kill it.Note that no jobs will run during the time it was stopped.

Also, why kill -9 on first attempt?? You can safely,do as follows.

kill -15
kill -1
kill -2
kill -3
kill -11

and then kill -9. kill -11is equallyeffective and does memory cleanup that kill -15 doesnot do.
There is no substitute to HARDWORK
Bill Hassell
Honored Contributor

Re: Cron does not stop

cron should not be stopped to prevent a job from running. Just use crontab -l to create a local file to edit the current cron set. Then comment out the job you do not want to run and resubmit this cile to cron using crontab.


Bill Hassell, sysadmin
Indrajit_1
Valued Contributor

Re: Cron does not stop

Hi;

you no need to stop cron service in terms to stop any running job by cron. Do the follwoing step

#crontab -e (edit the file and comment the line for the service you want to stop)


cheers
indrajit
Never Ever Give Up
Steven E. Protter
Exalted Contributor

Re: Cron does not stop

Shalom Mukul,

As usual Bill is right. Further, if you can't get the cron daemon to stop, you may be spawning it in /etc/inittab

Thats a bad idea and you should check inittab and make sure what I'm guessing happened in fact did not happen.

cron daemon is started by root, process 1. A kill -9 will have no effect. If it was permitted to kill process 1, then your system would stop.

kill -9 just so you understand means kill the process and the parent. Its a waste of time to use it on processes whos parent id (PPID) is 1.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Doug Kratky
Frequent Advisor

Re: Cron does not stop


kill -9 does not mean kill the process and its parent. And, it still works fine if the PPID is 1.

You can use ps -ef to track down children of cron to see why it might not be stopping. If you have jobs spawned by cron that don't exit, you should track those down as they can cause problems.

I agree with others that it's not customary to stop cron for an application upgrade. You're better off editing crontab entries if possible. But, stopping cron should work if you want it to.