The section (if block) where you call mailx is on the condition that $pid is zero length.
So you cannot send an "empty" pid and be able to read it. So, help me here. What are you trying to do?
welp the first thing is, i check if the other batch is running,
if it is NOT running $pid="" (empty) which means there is no pid running with that grep, THEN, restart the process, then exit.
If it is running, the current or new pid started moments ago with above NOT statement, THEN, simply do nothing, echo "running", no log needed.
If it is NOT running, restart, grab the NEW $pid and email that new pid with mailx, AND echo the restarted to the log file.
everything is a go, perms wise, this script restarts the dead script. but it hangs, i want it to ALSO exit out with zero exit status and recheck via crontab every 1 min. this is a HA server, and needs constant babying lol. it doesn't cry much, but when it does, people lose jobs.
thanks for your help again, i appreciate it.
anymore input, just ask
So, does:
just restart the process asynchronously and exit, or is it supposed to run forever? Does the trace of the script produced by sh -x show that the two sleeps, mailx, date, and echo are run when the batch is not running? Should:
be changed to:
Why does your script initialize BATPF twice?
Why bother setting pid to an empty string just before exiting when the service is running?
Last edited by Don Cragun; 06-06-2013 at 09:20 PM..
Reason: fix auto spell correction glitches
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!
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.
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?
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...
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.
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)
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)
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)
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)
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)
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)
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)