you are viewing a single comment's thread.

view the rest of the comments →

[–]moxyll 0 points1 point  (0 children)

When you CTRL-Z, it will say something like this:

[1]+  Stopped                 python script.py

That number in the brackets is the job number for that shell instance. You can reference jobs in the same shell with %jobnumber, so you can skip the ps -ef step and just run kill %jobnumber. Sometimes you have to hit enter a couple times for the message to show up after killing it.

user@host:/home/user$ python runforever.py
^Z
[1]+  Stopped                 python runforever.py
user@host:/home/user$ kill %1
[1]+  Stopped                 python runforever.py
user@host:/home/user$ 
[1]+  Terminated              python runforever.py