2016-07-27 35 views
-1

können sagen, was wir tun:Ubuntu nohup Shutdown-spezifische Skript

sudo nohup ./start.sh process1

sudo nohup ./start.sh process2

sudo nohup ./start.sh process3

./start.sh läuft eine Python-Datei, die für immer loops.

Nun, wie töte ich das 'process2'?

Ich kann killall python tun und alle von ihnen würde heruntergefahren werden. Ist es möglich, "proccess2" spezifisch zu töten, um es irgendwie zu markieren?

+0

versuchen; jobs -l und gefunden pid und kill -9

+2

Sie können auf laufende Prozesse aussehen: 'ps -ef' und dann grep für Python oder eine andere Identifikation Ihres Prozesses:' ps -ef | grep python – andlrc

+0

@ M.Dogru Ich bekomme nichts, wenn ich 'jobs -l' seltsam mache. @andlrc Danke, das habe ich gebraucht. – Alice

Antwort

0

Sie können dies versuchen;

[email protected]:/tmp/pythontest$ cat start.sh 
#!/bin/sh 
/usr/bin/python /tmp/pythontest/$1 & 

[email protected]:/tmp/pythontest$ ./start.sh test1.py 
[email protected]:/tmp/pythontest$ ./start.sh test1.py 
[email protected]:/tmp/pythontest$ ./start.sh test1.py 

[email protected]:/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 

Zweites Feld ist die PID-Nummer.

[email protected]:/tmp/pythontest$ kill -9 19449 

[email protected]:/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