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.