Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



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

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-14-2010
Registered User
 

Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Script for grepping status

I'm a newb so please be kind. I'm trying to write a script to check the status of a program running on a vncserver to know whether or not it has ended and if I need to restart the server. Here's what I've got and please I am a self taught scripter:

if [ ps ax | grep xterm | awk '{print $5}' = "xterm" ] then
serv-restart
fi

I've been searching and am not quite sure how to make work. Any hints or pointers is extremely appreciated.
Sponsored Links
    #2  
Old 03-14-2010
dennis.jacob's Avatar
Registered User
 

Join Date: Feb 2007
Location: Singapore/Cochin
Posts: 871
Thanks: 0
Thanked 10 Times in 9 Posts
You can try :


Code:
if ps -ef | grep -q 'pattern_to_srch'
then
 echo "Available,";
else
 echo "Not available,  do retsart"
...restart logic...
fi

Sponsored Links
    #3  
Old 03-14-2010
frans's Avatar
frans frans is offline Forum Advisor  
Registered User
 

Join Date: Oct 2009
Location: France
Posts: 837
Thanks: 4
Thanked 52 Times in 51 Posts
pgrep can be your friend on Linux
    #4  
Old 03-14-2010
Registered User
 

Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
preliminary result are the pgrep will work perfectly. just have to do some testing. will let you know.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to check status of a PID zeekblack Shell Programming and Scripting 14 10-03-2006 03:09 PM
Installing RedHat 8.0 onto Dell PowerEdge SC1425 - hdc: status error: status = 0x58 fishsponge Red Hat 5 07-14-2006 02:53 PM
CronTab script exit status 134 VijayKumar Shell Programming and Scripting 3 03-24-2005 10:56 PM
status of perl script in another ... jo_aze Shell Programming and Scripting 4 08-05-2003 08:19 AM
Couldn't open status file /var/samba/STATUS.LCK macdonto UNIX for Dummies Questions & Answers 2 08-08-2001 08:42 AM



All times are GMT -4. The time now is 03:46 AM.