kill -9 not working

Hi All,

I tried killing a bunch of scripts. They seem to have worked because
ps -ef | grep -i SCRIPT_NAME is not showing them but the logs are getting populated and jobs in the script are getting done.

How do I really kill them or atleast see the process running?

Thanks
Sumeet

Have you got "lsof" installed ? If so try running "lsof filename" and it will give you the pid of the process that has that file open (BTW, the title of the post is a bit misleading as the "kill -9" worked (and should always work unless there is a hardware fault), however there are still other processes that are writing to the files)

I hope this helps...

"lsof filename"

Which filename are we talking about? The script,log,cron,etc?

Yep the subject is misguiding.

You mentioned the logs were getting populated ? Run "lsof" on those (unless they are syslog logs, in which case the syslog entry will usually give you the pid of the program that is logging the entry)

Its not working. But your point is right if we are able to find which pid is writing into the file then we can kill it. This is what I got -

aaau001:/datamart/log/script> lsof poll.PPM.output.012411.0002
aaau001:/datamart/log/script>

Basically got back nothing.

Is this the same script you were developing a while back and were running from cron? The log filename in the script looks similar.
http://www.unix.com/shell-programming-scripting/144806-unexpected-results-when-triggered-cron.html

If so, you may well need to comment out the cron to stop the poll.

Hey Methyl,

Thats the first thing I did yesterday. I commented the cron jobs -

crontab -l
#02 00 * * * /datamart/scripts/DM_PollScript.ksh PPM2DM* PROD waitfile > /datamart/log/script/PPM2DM.log

#01 00 * * * /datamart/scripts/DM_PollScript.ksh Peb* PROD waitfile > /datamart/log/script/Pebbles.log

And surprisingly they got triggered again today. I am clueless where are they getting triggered from and How to stop it.

It is just ruining all other jobs.

Thanks

---------- Post updated at 01:07 PM ---------- Previous update was at 01:06 PM ----------

And today I cant even see the poll script process running when I do -

ps -ef | grep -i poll

Are you user "root"?
Is this a "root" cron?
How long have these crons been running live?
Could there be lots of copies running?

I wonder if the script contains some sort of perpetual loop and it never stops?
What's in the script?
How do you normally stop the script?

Its not running as root. Its a different user.

These scripts start just after midnight daily and poll for a file every 15 mins. There is a timer in the script which ends the scripts once 1340 mins have elapsed. So it dies automatically towards the end of the day.

If you look at the log file timestamps, yesterdays script finished at aroung 11:25 PM and new set of scripts got triggered early morning even though there were commented in the cron file -

-rw-r--r--   1 estdm2   datamart   15607 Jan 24 22:46 poll.Peb.output.012411.0001
-rw-r--r--   1 estdm2   datamart   14836 Jan 24 22:46 poll.HSA.output.012411.0001
-rw-r--r--   1 estdm2   datamart   13231 Jan 24 22:48 poll.OES.output.012411.0003
-rw-r--r--   1 estdm2   datamart   13821 Jan 24 23:02 poll.PPM.output.012411.0002
-rw-r--r--   1 estdm2   datamart   14530 Jan 24 23:17 poll.DM-.output.012411.0002
-rw-r--r--   1 estdm2   datamart     188 Jan 25 00:01 HHSAS.log
-rw-r--r--   1 estdm2   datamart     193 Jan 25 00:01 Pebbles.log
-rw-r--r--   1 estdm2   datamart     188 Jan 25 00:02 PPM2DM.log
-rw-r--r--   1 estdm2   datamart     191 Jan 25 00:02 REMEDY.log
-rw-r--r--   1 estdm2   datamart     185 Jan 25 00:03 OES.log
-rw-r--r--   1 estdm2   datamart    5077 Jan 25 11:46 poll.Peb.output.012511.0001
-rw-r--r--   1 estdm2   datamart    4838 Jan 25 11:46 poll.HSA.output.012511.0001
-rw-r--r--   1 estdm2   datamart    4600 Jan 25 11:47 poll.PPM.output.012511.0002
-rw-r--r--   1 estdm2   datamart    4885 Jan 25 11:47 poll.DM-.output.012511.0002
-rw-r--r--   1 estdm2   datamart    4549 Jan 25 11:48 poll.OES.output.012511.0003

I am trying to figure out how this cron is triggering even though I have commented it.

Should I open a new thread?

Thanks
Sumeet

Have you looked in the cron log (usually /var/adm/cron/log but check your "man cron" page) to check if these jobs are still being invoked by cron?

Stating the obvious, but did you use "crontab -e" to edit the crontab - or some other method?

As this is a non-root cron, do you find processes with likely start times with say:

ps -fu<username>
i.e.
ps -fuestdm2

I'm still theorising that the script never stops and that it interrogates the date inside a sleep loop which causes the filename to change. Big guess.

ps -fu estdm2 does not give the poll script process.

I dont have read permissions on cron log. I have requested for bouncing the server.

I dont use crontab -e. I have a file with cron entries and I bind that with crontab - crontab cron.

You might have syntax errors in your crontab that prevent it from using it, keeping the old one instead.

Does it give anything which is not attached to a terminal or which has high CPU usage?
It may just show as a Shell process with no command line. You may have killed the parent process.

A "kill -9" is a last resort and can leave orphan looping processes - similar to when users don't log out properly. If you have orphan looping processes they should show with the "top" command. Be careful because a busy database process could look similar.

We kill looping processes sometimes. The most common are shell menu scripts.