Sponsored Content
Top Forums Shell Programming and Scripting Shell script for process monitoring Post 302526467 by radoulov on Tuesday 31st of May 2011 03:12:52 PM
Old 05-31-2011
Which OS are you using?

Assuming you want to monitor a process named atd and pidof is available:

Code:
#!/bin/bash

_prg=atd
_logfile=monitor.log

while sleep 60; do                                        # poll every minute ...
  pgrep -f "$_prg" >/dev/null || {                        # if process not available
    start atd  >/dev/null 2>&1                            # start it and log the operation
    printf '[%s] %s started with pid %d at %s\n' \
      "$( date )" "$_prg" $( pgrep -f "$_prg" ) >> "$_logfile"
      }
done

If pgrep is not available, you may try some of these:

Code:
ps -C <your_program> -o pid=

The last option could be something like this (assuming your process is atd):

Code:
ps -eo pid,args= | grep '[a]td' |cut -d\  -f2

Bare in mind, that if you're starting your process in background, its pid will be available in the $! variable (so you won't need all the stuff above).

Last edited by radoulov; 05-31-2011 at 05:36 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Process Monitoring Script Help

I have a shell script which runs from 7AM to 3AM every day. The script performs certain monitoring functions and if it has a problem it may need to email someone about it. The problem is that the notification process was never modified to handle running past midnight (from 23:59:59 till 3AM). ... (0 Replies)
Discussion started by: rdc69
0 Replies

2. Shell Programming and Scripting

Weblogic monitoring shell script

HI, I'm new in unix. I would like to know if you have a ready script for monitoring the weblogic and managed servers. I want to have a script that checks the weblogic once in a while if it's up and running. if not running, will send an email to me. any idea? please help me. i will... (4 Replies)
Discussion started by: tungaw2004
4 Replies

3. Shell Programming and Scripting

Process Monitoring Script

I need a script on Solaris 10 OS to monitor 3 seperate processes running. Each process has 3 of the same processes running a total of 9 processes and I need the ability to know if all of processes for each process is running and to email me if they aren't running. I'm new to Unix programming and... (3 Replies)
Discussion started by: soupbone38
3 Replies

4. Shell Programming and Scripting

Error in script to automate the daily monitoring process of UNIX server and it's proc

hi friends, I am trying to automate the daily monitoring process of UNIX server and it's processes. the script are below i executed the above script using ksh -x monitortest1.sh in root login . It shows error at some lines . 1. i logged in using root ,but it... (8 Replies)
Discussion started by: rdhaprakasam
8 Replies

5. Shell Programming and Scripting

Help on Process Monitoring Script

Hi All, I have a Java application running in the background which process looks like this. java -DMyService=Y -DWorkingDir And I have a monitoring script which looks like this; count_service=`ps -aef | grep MyService | wc -l` if ; then echo "Service_Stopped on `date`" >>... (6 Replies)
Discussion started by: swmk
6 Replies

6. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it This is how we execute the script (and this is the requirement) ... (2 Replies)
Discussion started by: jonnyvic
2 Replies

7. Shell Programming and Scripting

need help with a process monitoring script

GM everyone, I have this script that goes to multiple servers and monitor a certain process and send the output to a file on servers1, the script looks like this exec < server.list while read SERVER do ssh $SERVER "ps -ef | grep process_name" >> /tmp/report done can someone help ad... (0 Replies)
Discussion started by: baders
0 Replies

8. Shell Programming and Scripting

Need help with my process monitoring script

GM everyone, I have this script that goes to multiple servers and monitor a certain process and send the output to a file on servers1, the script looks like this Code: exec < server.listwhile read SERVER do ssh $SERVER "ps -ef | grep process_name" >> /tmp/reportdone can someone help me... (2 Replies)
Discussion started by: baders
2 Replies

9. Shell Programming and Scripting

Shell Monitoring Script

Hi guys, I didn't understand this monitoring script request - I don't ask for the script result. If you understand the request, I'm just asking an explanation to simplify it for me. THE Script Request: Our organization keeps various files in directories structured as... (2 Replies)
Discussion started by: moshesa
2 Replies

10. Shell Programming and Scripting

Monitoring processes in parallel and process log file after process exits

I am writing a script to kick off a process to gather logs on multiple nodes in parallel using "&". These processes create individual log files. Which I would like to filter and convert in CSV format after they are complete. I am facing following issues: 1. Monitor all Processes parallelly.... (5 Replies)
Discussion started by: shunya
5 Replies
OPAL-RESTART(1) 						     Open MPI							   OPAL-RESTART(1)

NAME
opal-restart - Restart a previously checkpointed sequential process using the Open PAL Checkpoint/Restart Service (CRS) Note: This should only be used by the user if the application being restarted is an OPAL-only application. If it is an Open RTE or Open MPI program their respective tools should be used. SYNOPSIS
opal-restart [ options ] <SNAPSHOT HANDLE> Options opal-restart will attempt to restart a previously checkpointed squential process from the snapshot handle reference returned by opal_check- point. <SNAPSHOT HANDLE> The snapshot handle reference returned by opal_checkpoint, used to restart the process. This is required to be the last argument to this command. -h | --help Display help for this command --fork Fork off a new process, which is the restarted process. By default, the restarted process will replace opal-restart process. -w | --where The location of the local snapshot reference. -s | --self Restart this process using the self CRS component. This component is a special case, all other CRS components are automatically detected. -v | --verbose Enable verbose output for debugging. -gmca | --gmca <key> <value> Pass global MCA parameters that are applicable to all contexts. <key> is the parameter name; <value> is the parameter value. -mca | --mca <key> <value> Send arguments to various MCA modules. DESCRIPTION
opal-restart can be invoked multiple, non-overlapping times. This allows the user to restart a previously running sequential process. See opal_crs(7) for more information about the CRS framework and components. When using the self CRS component, the <FILENAME> argument is replaced by the name of the program to be restarted followed by any arguments that need to be passed to the program. For example, if under normal execution we would start our program "foo" as: shell$ setenv OMPI_MCA_crs=self shell$ setenv OMPI_MCA_crs_self_prefix=my_callback_prefix shell$ ./foo arg1 arg2 To restart this process, we may only need to call: shell$ opal-restart --self -mca crs_self_prefix my_callback_prefix ./foo arg1 arg2 This will cause the "my_callback_prefix-restart" function to be called as soon as the program "foo" calls OPAL_INIT. You do not have to call your program with the same argument set as before. There for we could have just as correctly called: shell$ opal-restart --self -mca crs_self_prefix my_callback_prefix ./foo arg3 This depends upon the behavior of the program "foo". SEE ALSO
opal-checkpoint(1), opal_crs(7) 1.4.5 Feb 10, 2012 OPAL-RESTART(1)
All times are GMT -4. The time now is 10:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy