![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. |
|
||||
|
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 |
|
||||
|
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}' |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|