Forum OpenACS Q&A: Aolserver restarts

Collapse
Posted by Richard Hamilton on
I am no bash expert but would love to be able to kill as aolserver instance like this :

kill -9 | cat nspid.servername

But of course this doesn't work because it would be far too simple to have something obvious like that work!

Presumably I need some super clever, cryptic hieroglyphics to turn the text output of the cat command into a suitable input to the kill command.

Can anyone help?

Regards
Richard

Collapse
2: Re: Aolserver restarts (response to 1)
Posted by C. R. Oldham on
kill -9 `cat nspid`
Collapse
3: Re: Aolserver restarts (response to 1)
Posted by Don Baccus on
Those are left-pointing accents not apostrophes, just in case it's not clear, richard!

This shell construct is in general very useful.  For instance, to edit every file in a directory tree containing the string "foo":

vi `grep -r -l foo .`

Collapse
4: Re: Aolserver restarts (response to 1)
Posted by Richard Hamilton on
Brilliant - thank you!

I shall enjoy that...........

Collapse
5: Re: Aolserver restarts (response to 4)
Posted by Guan Yang on
You need to look at the pgrep and pkill commands. They grep and kill processes based on regular expressions. Especially note the -f options to these commands.
Collapse
6: SIGTERM vs. SIGKILL (response to 1)
Posted by russ m on
C.R. 's command is correct, but I'd also suggest you shouldn't be using kill -9 unless it's absolutely nescessary. kill -9 sends a SIGKILL signal, which amounts to pulling the plug on the process without giving it any time to clean up after itself. The default signal to send (if you leave out the -9) is a SIGTERM which tells the process to shut itself down and do any cleanup that is required. Only if the SIGTERM doesn't work (which means your AOLserver is extremely wedged) should you use a SIGKILL.

So you generally want to use kill `cat /path/to/nspid` to stop the server, and only go for kill -9 `cat /path/to/nspid` when your AOLserver process doesn't respond to a regular shutdown request.