Wednesday, March 25, 2015

How to stop a background process in linux system

Leave a Comment
How to stop a background process in linux system? How many to stop a background process in linux system

For example running a background process:
# python server.py &

Method 1: use jobs command

[root@localhost project]# jobs
[1]+  Running                 python server.py &
[root@localhost project]# kill %1
[root@localhost project]# jobs
[1]+  Terminated              python server.py

Method 2: use ps command

[root@localhost project]# ps aux | grep server.py
root      1244  0.0  0.8  11068  4312 pts/0    S    16:47   0:00 python server.py
root      1246  0.0  0.1   4356   740 pts/0    S+   16:47   0:00 grep server.py
[root@localhost project]# kill -9 1244

Method 3: use fg to bring a background job back to foreground.

[root@localhost project]# jobs
[1]+  Running                 python server.py &
[root@localhost project]# fg 1
python server.py
^C
Copyright by: www.linuxoperatingsystem.info http://goo.gl/kMscJ4

0 comments:

Post a Comment