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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Killing of a process and send a mail if the process doesnot come up within 2 minutes Prince89 Shell Programming and Scripting 1 02-15-2008 07:10 PM
how to check if a process is running in a server from shell script. debu UNIX for Advanced & Expert Users 2 01-24-2008 05:19 PM
How to create a dummy process of a process already running? shambhu UNIX for Advanced & Expert Users 3 08-31-2007 11:22 AM
how to get the list of process running in the server from the local machin n unix ? guhas Shell Programming and Scripting 3 10-04-2005 04:58 PM
How to monitor if a process is running Pedro Tavares High Level Programming 3 11-14-2001 03:34 PM

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

Join Date: Sep 2008
Posts: 2
m not able to run script gives by pradeepmacha

hi
while i tried for to run script
[#!/bin/ksh
pid=""
pid='ps -ef | grep "<process string>" | awk ' {print $2}''
echo $pid
if [ "$pid"="" ]
then
echo "process not running"
rsh <mail server> mailx -s "<etc etc process not running>" <mail.id>
else
echo "service is ok"
pid=""
fi
]

i got errors that are :
./pname.sh: line 1: [#!/bin/ksh: No such file or directory
./pname.sh: line 3: {print: command not found

process not running
./pname.sh: line 12: ]: command not found


i m new in linux environment and need ur favour. plz how to compile this script.

actually i need a command fron that maps process name to process id.
thx.
  #2 (permalink)  
Old 03-06-2009
centurygalactus centurygalactus is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 1
script to monitor process running on server and posting a mail if any process is dead

Hi, This is the answer to your query.

bash-3.00$ vi ProcessMonitoring.sh
#!/bin/ksh
puser=1
for name in `cat perf_listfile`
do
puser=`ps -ef | grep $name |grep root | awk ' {print $1}'`
#puser=`ps -ef | grep "jogi" |grep root | awk ' {print $1}'`
echo $puser
echo $pid
if [ $puser -eq root ]
then
echo "successful"
else
echo "This is an auto-generated mail for Process Monitoring Error. Process $name not running. From : Error Monitoring Process." | mailx -s "Process Monitoring Error : $name not running" centurygalactus@gmail.com
fi
done
  #3 (permalink)  
Old 07-12-2005
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
hi,

the script that u had posted

#!/bin/ksh
pid=""
pid='ps -ef | grep "<process string>" | awk ' {print $2}''
echo $pid
if [ "$pid"="" ]
then
echo "process not running"
rsh <mail server> mailx -s "<etc etc process not running>" <mail.id>
else
echo service is ok
pid=""
fi


will always return a pid since grep is a process, ( u will not receive process not running message even though the actual process isnt running) need to trip off the process grep when checking for other process pids and what if the other user has the same process, u would end up with pids that are not under your control.

you can try this,
ps -ef | grep <user> | grep -v grep | grep <process string> | awk '{print $2}'
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:54 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