Sponsored Content
Top Forums Shell Programming and Scripting [Solved] Unable to mailx new $pid for a script restart Post 302818049 by Don Cragun on Friday 7th of June 2013 12:43:44 AM
Old 06-07-2013
Quote:
Originally Posted by olyanderson
i copied this script from elsewhere, i am learning. i am glad you gave some input. thanks. to answer your questions to help:

1. Why does your script initialize BATPF twice?
it doesn't, typo, it will be removed. thanks for noticing that DON!
You're welcome.
Quote:
Originally Posted by olyanderson
2. yes it does start a process - another script, a batch script actually that is suppose to run and accept requests to a client driven db - we won't get into that.
If you want to fix the problem, we need to get into that. The changes I suggested should work if the script starts the batch script and waits for it to complete. If you would have shown us the trace output produced by /usr/bin/sh -x, we might be able to give you a definitive answer; without seeing that output or seeing what is in /usr/script8/batch/bat_fstsi61c.sh, we can only make wilde guesses (like I did before).

If /usr/script8/batch/bat_fstsi61c.sh is the batch script and it doesn't return until it is killed, what I suggested should work. If /usr/script8/batch/bat_fstsi61c.sh asynchronously starts the batch script and returns without waiting for it to complete, what I suggested will not work. In that case you'll need to rerun the ps pipeline to reset pid after the batch process is restarted. You wait 20 seconds after /usr/script8/batch/bat_fstsi61c.sh returns (if it returns) before saving $pid in your log file, but you haven't reset pid so you know it has to be an empty string whether or not the batch script restarted successfully.
Quote:
Originally Posted by olyanderson
3. Why bother setting pid to an empty string just before exiting when the service is running?
I didn't, I do not know what I am doing. I'm trying though.

The sleep is there in the hopes that it will produce a new $pid, that is one thing that is puzzling me the most.

Like I said before, the script runs fine ( the one this is calling ) and needs to be online 24/7. This script is supposed to CHECK to see if ANY pid matches the grep in BATPF. it takes 10 seconds for a new pid to be reproduced. I am trying to wait/sleep/capture that new pid in the "if".

Is there a better way?
There are two scripts. You are talking as though there is only one. Until you understand that there are two and how they interact, we're lost. If you actually mean that the script above is the contents of /usr/script8/batch/bat_fstsi61c.sh, then your description of what is going on is extremely confusing and could be rewritten in a much simpler fashion.
Quote:
Originally Posted by olyanderson
Don I will try to do the steps you suggested. Looks like it will work. But remember, I need this script to end. so running it in background process with & looks great, but will take 10 seconds for that new pid to come avail? If I start the backend script, it takes a few mins to produce a pid(the backend is a db starting with a client) and usually takes same amount of time for pid via ps and grep to show its not there - aka gracefully shutdown that connection. DB is heavy transaction based.

thanks, hope that helps. pls ask anything more. thanks guys...
If the script isn't ending when it restarts the batch process, my guess still fits the data you're seeing. But until you show us the trace output you got from running this script or show us the contents of /usr/script8/batch/bat_fstsi61c.sh, we are just guessing.
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

unable to do mailx from shell script

Hi From within a shell script my mailx doesnt seem to work...can somebody tell me what is wrong... #!/bin/ksh #Script to verify wheather all databases listed are up and running #Script works with Oracle8 and above databases #Script has to be run by ./scriptname DBA=xiamin@unix.com echo... (3 Replies)
Discussion started by: xiamin
3 Replies

2. Linux

mailx: Unable to send Japanese

Hi All, I am facing problem in sending Japanese characters using mailx command in GNU linux machine. The mail is going with junk characters like "メールの-界へようこそ". I tried changing the LANG value to japan locale off UTF-8. But it doesn't worked. I have to send the data as body not as an... (0 Replies)
Discussion started by: Karteek
0 Replies

3. Solaris

Unable to send mail through mailx

Hi, I am using solaris 5.9 OS and I am facing an issues with mailx. My SMTP port is configured to listen 6190 and not the default one which is 25. I can send mail to my inbox when i do it manually through the following steps root@<dbname> # telnet 15.12.88.10 6190 Trying 15.12.88.10...... (0 Replies)
Discussion started by: Srinathkiru
0 Replies

4. HP-UX

[Solved] mailx : unknown user issue

Hi all, I know this issues has been discussed multiple times, i have gone through many such discussion but unfortunately i am still not able to solve the issue being faced. I have configured the sendmail.cf with the smtp host name (Editing the entry starting with DS...) Post that restarted... (7 Replies)
Discussion started by: chpsam
7 Replies

5. Shell Programming and Scripting

[Solved] Unable to call a python script from bash

Hi, I am trying to run a python script embedded in bash script. But is throwing me an error. Please help. Script: #!/bin/bash nohup /usr/bin/python /opt/web/http.py & Error: /usr/bin/python: can't open file '/opt/web/http.py': No such file or directory Please help me on this. (6 Replies)
Discussion started by: maddy26615
6 Replies

6. Red Hat

Can't stop/restart postfix - pid associated with another process

This issue could happen to any other service but in this case its commssioning Postfix - it seems i can't stop postfix as the PID relates to another service - i've delete the 'master.lock' but to no available - any ideas, memeory commands etc ? thanks in advance ps. the serve is in Production so... (2 Replies)
Discussion started by: stevie_velvet
2 Replies

7. Shell Programming and Scripting

Unable to get pid from fuser

bash-3.2$ fuser -f /bin/nohup.out /bin/nohup.out: 13136o 13111o The pid is 13136. Can you tell me how can i extract just the pid 13136 from the above output ? bash-3.2$ uname -a SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v I was trying on this lines but i get strange... (3 Replies)
Discussion started by: mohtashims
3 Replies
All times are GMT -4. The time now is 02:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy