write a shell script so that it can run as service/daemon
Hi,
Am not sure of the best way to go about writing a script. All I need at the moment is to start a java http server program at startup. I have the following script for this... Code:
# /var/www/html/languagetool/languagetool.sh Code:
|
Code:
killall -9 java If you have other java instances that you don't want to kill at the same time, then you will have to grep the process list for the one you want. Run the script, start the java http program and then look in your process lists for the program. When you have identified the program, you could run something like this to stop that process : Code:
kill `ps -ef | grep my_java_program | grep -v grep | awk '{ print $2 }'` You could try using something like this for starting too : http://jlorenzen.blogspot.com/2007/1...p-scripts.html |
hi anyway to execute languagetool.sh in an asynchronous manner. When we start at service from the shell it blocks, and does not return to the prompt.
|
Is that a question ?
Check my link again, it tells you how to run the command in the background so your script can finish. |
I've written my script file as follows:
Code:
# /var/www/html/languagetool/languagetool.sh PS: its the java program thats blocking...not the script to be precise... |
You missed off the & at the end of the line.
Look at the example again. |
something wrong...the output file says
Code:
nice: java -cp jaminid.jar:LanguageTool.jar \ |
1) You don't need nice
2) why did you put single quotes around the command ? You didn't need them before. |
Do not use kill -9 in scripts, ever. It tells a process to "just die right now" without giving any opportunity for cleanup. It's meant only when you've got a runaway process that you need dead and you'll take responsibility for the fallout.
http://mywiki.wooledge.org/ProcessManagement |
@smoker its to demarcate that that is the command I am trying to execute. Actually thought that -cp (which is part of the java command structure) will be confused with nohup...
|
Quote:
nohup would not be confused by the -cp. See the nohup man page for why not. |
All times are GMT -5. The time now is 05:53 PM. |