Computing.Net > Forums > Unix > ksh script question re: hung processes

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

ksh script question re: hung processes

Reply to Message Icon

Name: LS
Date: August 27, 2001 at 09:58:13 Pacific
Comment:

I'm looking for a way to detect a hung ftp process running on a unix server. I have the pattern to grep for in the process list and the way we determine if this particular process is "hung" is if the start time is an hour (or more) old. For example, this is the "hung" process:
ecadmin 26123 26733 0.0 07:19:56 ?? 0:00.05 /usr/bin/ftp -niv ftp.companyname.com
My script will be running periodically - this process started at 07:19:56, so if the time is 08:19:56 or later, I want to kill -9 26123. How can I get the difference between the process start time and the current time or is there some other unix command(s) I can use to list this process if it's over 1 hour old? I obviously can't use the cpu time because it's hung and doesn't increment. Any help would be greatly appreciated...thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: stefan caunter
Date: August 31, 2001 at 21:15:47 Pacific
Reply:

a good way to get the time difference is to use unix seconds for the date stamp, i.e. seconds since jan 1 1970. if you can work the date command and its many options to convert the hh:mm:ss from the ps line into seconds, the math is very simple to establish a hung ftp process.
if you cut the hh:mm:ss fields and pass them as an argument to date -s it may be a way to start.
the other thing is you could do the grep and kill on a custom log for the ftp server instead of dealing with ps.
hope that helps


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: ksh script question re: hung processes

ksh script www.computing.net/answers/unix/ksh-script/6748.html

KSH Script-Need Help www.computing.net/answers/unix/ksh-scriptneed-help/5534.html

ksh/cron question www.computing.net/answers/unix/kshcron-question/5910.html