Sponsored Content
Top Forums Shell Programming and Scripting Bash shell script to check if script itself is running Post 302726595 by Yoda on Monday 5th of November 2012 12:09:17 AM
Old 11-05-2012
Please modify your if-else statement like below and re-try:-

Code:
if [ `ps -eaf | grep -v grep | grep -c $CHECK_SCRIPT` -ne 0 ]
then
      logger -s "$CHECK_SCRIPT is running. Do nothing"
else
      logger -s "$CHECK_SCRIPT is not running. Please restart script"
fi           

if [ `pgrep -l $SERVICE | grep -c $SERVICE` -ne 0 ]
then
      logger -s "$SERVICE process is running. Do nothing"
else
      logger -s "$SERVICE process is not running. Please restart service"
fi

This User Gave Thanks to Yoda For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to check if a process is running in a server from shell script.

I want to write a unix shell script that will check if a process (say debu) is running in the server or not. If no , then send a mail to the corresponding person to start the process??? (2 Replies)
Discussion started by: debu
2 Replies

2. Shell Programming and Scripting

script to check if another script is running and if so, then sleep for sometime and check again

Hi, I am a unix newbie. I need to write a script to check wheteher another script is still running. If it is, then sleep for 30m and then check again if the script is running. If the script has stopped running then, I need to come out of the loop. I am using RHEL 5.2 (2 Replies)
Discussion started by: mathews
2 Replies

3. Shell Programming and Scripting

Running matlab script from within bash script

Hi guys, I'm new to scripting and I'm wondering if I can run a matlab script from within a bash script. Basically, at the minute I have a bash script which creates a file "bottfile.xyz" I then import "bottfile.xyz" into matlab using importdata('bottfile.xyz'). Then I just run the matlab... (0 Replies)
Discussion started by: jhunter87
0 Replies

4. UNIX for Dummies Questions & Answers

Help Running a Check in Bash Script

Hey guys, so I wrote a small script that pretty much just takes in two numbers and counts from the first to the second, e.g. unknown-hacker|544> count.sh 1 3 1 2 3 My problem is I want to make it so that if you input invalid parameters, such as non-numerical characters, more than 2... (2 Replies)
Discussion started by: Duo11
2 Replies

5. Shell Programming and Scripting

bash script to check if a program is running

I'm a bit new to bash programming and I was assigned the job of writing a script that will check to see if a program server is running and to restart the program if it is not up. The script is supposed to check the program every hour (which I have looked up and I believe I know how to do) and send... (3 Replies)
Discussion started by: mcknz
3 Replies

6. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

7. Shell Programming and Scripting

Help with Check Syntax of Shell Script without Running

Hi Everyone, Is there any way ( generic) to check syntax of Shell Scripts without running it?? (4 Replies)
Discussion started by: roy121
4 Replies

8. UNIX for Beginners Questions & Answers

How to check if the script is already running?

I have one shell script in NAS shared location. Since NAS is mounted in many servers, script can be run from any of those servers. I want to make sure if the script is already running, it should not allow others to run it. I googled it and got some idea that i can touch one empty file in the... (8 Replies)
Discussion started by: thomasraj87
8 Replies

9. Shell Programming and Scripting

How to check day name is it saturday in bash shell script?

How to check the day name,is it saturday in bash shell script. If dayname = saturday then run the full load else run just the incremental loads end if Thank you very much for the helpful information. (4 Replies)
Discussion started by: cplusplus1
4 Replies

10. Shell Programming and Scripting

Check status of long running multiple curl commands in shell script

I am working on script. it reads a file which contains multiple lines Ex; curl --write-out %{http_code} --silent --output /dev/null http://hostname:port/input=1 curl --write-out %{http_code} --silent --output /dev/null http://hostname:port/input=2 curl --write-out %{http_code} --silent ... (2 Replies)
Discussion started by: oraclermanpt
2 Replies
send_nsca(1)						      General Commands Manual						      send_nsca(1)

NAME
send_nsca - send passive check results to an NSCA daemon SYNOPSIS
send_nsca -H <host_address> [-p port] [-to to_sec] [-d delim] [ -c config_file] DESCRIPTION
send_nsca This utility is used to send passive check results to the NSCA daemon. Host and Service check data that is to be sent to the NSCA daemon is read from standard input. Input should be provided in the following format (tab-delimited unless overriden with -d command line argument, one entry per line): Service Checks <host> <svc_description> <return_code> <plugin_output> Host Checks: <host> <return_code> <plugin_output> OPTIONS
host_address The IP address of the host running the NSCA daemon port The port on which the daemon is running - default is 5667 to_sec Number of seconds before connection attempt times out. (default timeout is 10 seconds) delim Delimiter to use when parsing input (defaults to a tab) config_file Name of config file to use SEE ALSO
nsca(1) FILES
/etc/nsca.cfg nsca server configuration /etc/send_nsca.cfg send_nsca configuration AUTHOR
NSCA was written by Ethan Galstad <nagios@nagios.org>. This manpage was written by sean finney <seanius@debian.org> for Debian (but it may be freely used, modified, and redistributed by others). nsca December 2005 send_nsca(1)
All times are GMT -4. The time now is 04:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy