Stopping command from terminal without stopping shell script that started that command

0

I have a script like this:

#!/var/bin/bash

tail -f /path/to/file.txt

tail -f /path/to/other/file

... `

How can I stop tail -f without stopping whole script?

Any idea?

Ivan

Posted 2013-09-18T08:42:10.760

Reputation: 9

Are you really asking "How do I stop a process in Unix?" http://superuser.com/questions/107543/bash-man-page-kill-pid-vs-kill-9-pid

– Ярослав Рахматуллин – 2013-09-18T09:37:26.623

http://www.tldp.org/LDP/intro-linux/html/sect_04_03.html -- 4.3.5.7. Interrupting your processes – Ярослав Рахматуллин – 2013-09-18T09:40:47.373

This question is easily solved by research – Ярослав Рахматуллин – 2013-09-18T09:42:22.113

Answers

0

In another shell you can write

 pgrep -lf tail

the output should be similar to this:

9845 tail -f /path/to/file.txt

PID of the process in this case is 9845 You can stop (kill) it with

kill 9845

if it doesn't function you can use kill -9 9845.

Note: if you kill the process of 1st "tail -f" line of the script, the script will proceed till the second "tail -f" (tail -f /path/to/other/file) and stops again there.

Hastur

Posted 2013-09-18T08:42:10.760

Reputation: 15 043