Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have loaded debian etch into my NAS and I am trying to use it to routinely extract information from a website. Since there are quite a lot of pages to download, I used the nohup command, like this:

nohup ./script.sh $

Then the script runs as expected, but suddenly I changed my mind and want to modifiy the script a bit before running it again. How can I terminate the script which is now running?

Thanks.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You can find the pid of the script using:

ps aux|grep script.sh

Then kill it using

kill -15 <the pid>

This sends the SIGTERM signal to the process, which can be caught to allow clean (graceful release of system resources). Alternatively, you can use the SIGQUIT process with -3, which is capable if generating a core file (if you want one).

share|improve this answer
    
info nohup said: "nohup runs the given COMMAND with hangup signals ignored". So kill -1 doesn't work. –  quanta Sep 7 '11 at 16:12
    
@quanta Yes, you're correct. –  Dana the Sane Sep 7 '11 at 16:26

nohup prevents the processes from receiving SIGHUP. So, you must use -15 (SIGTERM) or -9 (SIGKILL) with kill command.

share|improve this answer
    
SIGKILL should only be used as a last resort though, since system resources may not be freed gnu.org/s/hello/manual/libc/Termination-Signals.html –  Dana the Sane Sep 7 '11 at 16:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.