![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Restart script based on MD5sum | Bakes | Shell Programming and Scripting | 6 | 01-02-2009 11:32 AM |
| Process based code vs. Thread based code | rkalyankumar | UNIX for Advanced & Expert Users | 3 | 09-09-2008 09:55 AM |
| Restart process | brendan76 | SuSE | 3 | 02-26-2008 12:43 PM |
| need help to write script to check the process health and automatically restart it | dragondad | Shell Programming and Scripting | 1 | 10-31-2006 06:16 PM |
| suspend/restart a process in shell script | daneensign | Shell Programming and Scripting | 1 | 02-14-2006 12:43 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
restart process based on file
Hi all.
I do have a script "startApp.sh" (app result is a file /opt/extract/appextract.txt) I have no problems with stopping app Code:
var1=`ps -ef | grep -v grep | grep MyApp | awk '{print $2}'`
kill -9 $var1
I start app, app is doing some extraction, after extraction is done i would like to stop app (kill app if/when) wait some time (~ 30 sec. different processes/scripts taking place) and start app again (until next extract) I will try to be more schematic - start App - app is running, doing stuff, and creates a file - when file is created I have to stopApp - wait ~30sec - start app Could you please guide me how to create some script that will be in "constant loop" or a service and will watch for that file, if exist do somethinh (kill my app) thank you very much e-l-diablo Use CODE-tags when displaying code, data or logs to enhance readability and to preserve formatting like indention etc., ty. Last edited by zaxxon; 07-21-2009 at 07:15 AM.. Reason: code tags |
|
||||
|
perfect.
Wht I dod not think about that. That is what I was searching for. I will give a try and let you know if it works as it should (there are more scripts in that process) very, very much thank you (i will do some modifications, i already see some options) |
|
||||
|
Hi again. After testing it does not work
What i have done: I have script called startMe.sh. It starts app and should kill when file in specific directory exists. Code:
#!/bin/sh
rm /opt/tmp/restart.txt *that removes restart file if exist
./startApp.sh
while :; do
if [[ -e /opt/tmp/restart.txt ]]; then
./killapp.sh
sleep 30
break
fi
done
./startApp.sh
exit 0
Code:
var1=`ps -ef | grep -v grep | grep java | grep username | awk '{print $2}'`
kill -9 $var1
|
|
||||
|
Hi.
Code:
*that removes restart file if exist Few more details. I am running Solaris 10 on SUN x4450 box (really nice work horse) with 128GB RAM. when I run ./startApp.sh all works as it should: my application starts and i get messages (all the time) Code:
./startApp.sh: [[: not found ./startApp.sh: [[: not found ./startApp.sh: [[: not found ./startApp.sh: [[: not found ./startApp.sh: [[: not found ./startApp.sh: [[: not found ./startApp.sh: [[: not found ./startApp.sh: [[: not found ./startApp.sh: [[: not found ./startApp.sh: [[: not found ./startApp.sh: [[: not found ./startApp.sh: [[: not found ./startApp.sh: [[: not found ./startApp.sh: [[: not found |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|