The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
zombie processes and hung process termination ukndoit Shell Programming and Scripting 2 03-14-2008 02:53 AM
Monitoring Processes - Killing hung processes ukndoit UNIX for Advanced & Expert Users 4 01-17-2008 04:30 AM
process monitoring eric_wong_ch Shell Programming and Scripting 3 10-11-2007 06:08 AM
SCO Openserver 5.0.7 Hung process problem josramon UNIX for Dummies Questions & Answers 0 04-25-2006 04:51 PM
Monitoring ftp process arkhewit UNIX for Dummies Questions & Answers 2 06-29-2005 06:56 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-08-2008
prismtx prismtx is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 24
Monitoring for a hung process

A coworker has a shell script that runs from a scheduler at the 3am. The shell script runs sqlplus passing in a sql statement, which generate a file. This is done 21 times for 21 different sql statements. Recently, one of the sqlplus processes got hung.

Is there a way to monitor how long the shell script takes to run, and kill it if it takes longer than, lets say, an hour. Or to monitor the time the individual sql's run?
  #2 (permalink)  
Old 03-08-2008
TonyLawrence TonyLawrence is offline
Registered User
  
 

Join Date: Sep 2007
Location: SE Mass
Posts: 137
Assuming you can't spawn these off to separate shells where you would:

thatprog &
$progid=$!
sleep $sleeptime
kill $progid

But if you need to be doing other stuff in between, generally you'd capture the PID's of the processes when they start, then watch for those processes still running ("ps -p $pid" if you are using shell), killing them when your conditions dictate.

You might also be able to use "ulimit -t" to set maximum cpu time used if that makes sense.

--
Tony Lawrence
Unix, Linux, Mac OS X Help, Tutorials and support pages
  #3 (permalink)  
Old 03-08-2008
prismtx prismtx is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 24
Thanks Tony. I'll check with my coworker on Monday. I haven't seen the script yet, just an email looking for help.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0