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
# 8  
Old 11-04-2013
Hi Jim,

As you suggested I was tried to find out solution for exiting script running in background but this time script run for two continuous days and then its suddenly stops even I checked with nohup.out for cause I found nothing. Could you please tell me how should i come to know what is the exact cause behind this…please find below code I am using within script.
Code:
#!/bin/bash
o=$IFS
IFS=$(echo -en "\n\b")
#date1=`date +'%Y-%m-%d'`
tail -n -0 -F /home/ketan/logs/KETAN-COMMON-ERROR.log | while read myline; do
        ERROR_CODE=$(echo $myline | awk -F ' ' '{for (i=1;i<=NF;i++){if($i ~ "^[1-1]" && length($i)==6){print $i}}}')
        ERROR_CODE_DET=$(echo $myline | awk -F ' ' '{print $1" "$2}')
if [ -n "$ERROR_CODE" ] ; then
                        echo $ERROR_CODE_DET
                        while IFS='|' read -r code disc; do
                        if [ "$ERROR_CODE" -eq "$code" ] ; then
                                echo "sudo snmptrap is triggered with ERROR CODE : $code and ERROR MSG : $disc"
                        fi
                        done < ERROR_CODES.txt
fi
done
IFS=$o



ERROR_CODES.txt contain list of error code and discription saparated by "|
"
120011|Route failed.
Regards,
ketanr
# 9  
Old 11-04-2013
Looks like your tail -F command stops after two days. As you are using bash, you may want to examine the PIPESTATUS array in the script to see what went wrong, or check what happened to the ...ERROR.log file
# 10  
Old 11-13-2013
Hi RudiC,

As suggested I found that input ...ERROR.log file is only get appended when there are logs for specific process is generated else it will remain idle unresponsive for long amount of time, is this a reason why my script getting exited if it’s not received any input from ERROR.log file for long time duration? If yes then could please explain me what is ideal time Linux system keeps process running in background idle and terminate when time exited? ....please help...
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