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
what are some different commands in c shell and korn shell?? EquinoX UNIX for Dummies Questions & Answers 1 01-29-2008 12:14 AM
bourne shell or korn shell? XZOR UNIX for Dummies Questions & Answers 2 10-06-2006 02:34 AM
how to convert from korn shell to normal shell with this code? forevercalz Shell Programming and Scripting 21 11-23-2005 02:18 AM
KORN Shell - Spawn new shell with commands frustrated1 Shell Programming and Scripting 2 04-20-2005 02:23 PM
AWK question in the KORN shell penfold Shell Programming and Scripting 11 02-09-2005 09:14 AM

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-25-2005
gpanesar gpanesar is offline
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
  #2 (permalink)  
Old 03-25-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

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

if (( $(ps -ef | grep -c [E]SP) > 0 )) ; then
   echo 'ESP is running'
else
   echo 'ESP is NOT running'
fi
  #3 (permalink)  
Old 03-25-2005
gpanesar gpanesar is offline
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?
  #4 (permalink)  
Old 03-25-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
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?
  #5 (permalink)  
Old 03-25-2005
gpanesar gpanesar is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 3
thanks for the help
Sponsored Links
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 01:04 AM.


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