|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
can anyone help on the following problem.
System Configuration : SunOS sun210 5.9 ----------------------------------------- I have two scripts "Master and Restart" script. - From the master script , I have to start, stop the restart script on certain conditions. - To achieve the above functionality, I need to get the processID of the restart script. But when i try the following script I am not able to get the processId. Sample Master Script ==================== ./restart.sh & while true; do if [ check for some condition ] then restartId=`ps -ef | grep "restart.sh" | grep -v "grep" | sed /zap/d | cut -c10-15` if [ -n "$restartId" ] then echo "Killing the restart script" kill -9 $restartId fi fi sleep 1 done - When I manually tried to '$ Ps -ef | grep restart.sh' , I could not see any process running. Is there any better and efficient way to do the above. Thanks and Regards, Vinoth vinoth.ilango@gmail.com |
|
#2
|
|||
|
|||
|
hi,
i've had to do something similar in the past a few times. i ended up getting the script that was being checked for to echo it's process id ($$) to a log file, and the master script then read that process id from the file... feels like a bodge, but it worked a treat |
|
#3
|
|||
|
|||
|
if i understand your probl, you need a prog
- starting something if not still running - stopping something if running - restart (this is stopp+start) something do it! 1) it's running ? 2) yes: exit, no: start! 3) required restart? kill it and restart this script btw: forget this stupidity restartId=`ps -ef | grep "restart.sh" | grep -v "grep" | sed /zap/d | cut -c10-15` i see you use SVR4 ps read man pages ps -efocomm|sed "s?.*$0 ??" check the output (at the moment i am not on *nix, change comm by args if not matching) |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Bash scripting |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|