The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
what are some different commands in c shell and korn shell?? EquinoX UNIX for Dummies Questions & Answers 1 01-28-2008 08:14 PM
bourne shell or korn shell? XZOR UNIX for Dummies Questions & Answers 2 10-05-2006 11:34 PM
how to convert from korn shell to normal shell with this code? forevercalz Shell Programming and Scripting 21 11-22-2005 10:18 PM
KORN Shell - Spawn new shell with commands frustrated1 Shell Programming and Scripting 2 04-20-2005 11:23 AM
AWK question in the KORN shell penfold Shell Programming and Scripting 11 02-09-2005 05:14 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-25-2005
Registered User
 

Join Date: Mar 2005
Posts: 3
Korn Shell

Hi I am new to shell programming. I need help to write a script to monitor a process on Sun OS. If the process fails then call a oracle procedure.

i check the process if running by typing

Code:
ps -ef | grep ESP | grep -v grep
    root 29002     1  0   Mar 18 ?        7:20 /u01p/system/ESPSystemAgent/cybAgent
thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-25-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 2,999
Code:
#!/bin/ksh

if (( $(ps -ef | grep -c [E]SP) > 0 )) ; then
   echo 'ESP is running'
else
   echo 'ESP is NOT running'
fi
Reply With Quote
  #3 (permalink)  
Old 03-25-2005
Registered User
 

Join Date: Mar 2005
Posts: 3
How would keep this job running all the time. will the job end if the grep process is not found

or i can i run it in the backround and leave the process on machine?
Reply With Quote
  #4 (permalink)  
Old 03-25-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 2,999
Quote:
Originally Posted by gpanesar
How would keep this job running all the time. will the job end if the grep process is not found
the script will exit either way. This was intended as a hint at the implementation - not a complete solution.

If you want to keep cheking for the job/process, you'll either:
  1. 'cron' [man crontab] the script to be ran at predefined times
  2. write the infinite look around the 'if' with the 'sleep #Seconds' to suspend the exucution for a '# of Seconds'
Quote:
Originally Posted by gpanesar
or i can i run it in the backround and leave the process on machine?
Reply With Quote
  #5 (permalink)  
Old 03-25-2005
Registered User
 

Join Date: Mar 2005
Posts: 3
thanks for the help
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0