Issue
lets say we do:
sudo nohup ./start.sh process1
sudo nohup ./start.sh process2
./start.sh
is running a python file that loops forever.
Now, how do I kill the 'process2'?
I can do killall python
and all of them would be shutdown.
Is it possible to kill 'proccess2' specifically somehow mark it or something?
Solution
You can try this;
user@host:/tmp/pythontest$ cat start.sh
#!/bin/sh
/usr/bin/python /tmp/pythontest/$1 &
user@host:/tmp/pythontest$ ./start.sh test1.py
user@host:/tmp/pythontest$ ./start.sh test1.py
user@host:/tmp/pythontest$ ./start.sh test1.py
user@host:/tmp/pythontest$ ps -ef | grep -i python
user 19447 2062 0 14:37 pts/32 00:00:00 /usr/bin/python /tmp/pythontest/test1.py
user 19449 2062 0 14:37 pts/32 00:00:00 /usr/bin/python /tmp/pythontest/test1.py
user 19451 2062 0 14:37 pts/32 00:00:00 /usr/bin/python /tmp/pythontest/test1.py
user 19454 11980 0 14:38 pts/32 00:00:00 grep --color=auto -i python
Second field is pid number.
user@host:/tmp/pythontest$ kill -9 19449
user@host:/tmp/pythontest$ ps -ef | grep -i python
user 19447 2062 0 14:37 pts/32 00:00:00 /usr/bin/python /tmp/pythontest/test1.py
user 19451 2062 0 14:37 pts/32 00:00:00 /usr/bin/python /tmp/pythontest/test1.py
user 19457 11980 0 14:38 pts/32 00:00:00 grep --color=auto -i python
Answered By - Mustafa DOGRU Answer Checked By - David Marino (WPSolving Volunteer)