ps, kill, pkill, top, nohup - oregon state...
TRANSCRIPT
![Page 1: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/1.jpg)
ps, kill, pkill, top, nohup
![Page 2: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/2.jpg)
‣ ps provides a snapshot current processes
UNIX> ps
PID TTY TIME CMD
5184 pts/0 00:00:00 bash
5215 pts/0 00:00:00 ps
![Page 3: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/3.jpg)
UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215 pts/0 00:00:00 ps
‣ PID: Process ID ‣ TTY: owning terminal ‣ TIME: process runtime ‣ CMD: command
![Page 4: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/4.jpg)
‣ -A option for ALL processes
UNIX> ps –A
PID TTY TIME CMD
1 ? 00:00:01 init
…….
29541 ? 00:00:03 update-notifier
29915 ? 00:00:00 gtk-logout-help
![Page 5: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/5.jpg)
‣ LOTS of processes running… – most control the OS (so don’t kill them)
UNIX> ps –A | wc –l 277 UNIX>ps -A | grep daemon | head –n 2 1729 ? 00:00:03 dbus-daemon 1742 ? 00:00:33 avahi-daemon
![Page 6: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/6.jpg)
‣ -u option specifies the user
UNIX> ps –u qhan
PID TTY TIME CMD
5183 ? 00:00:00 sshd
5184 pts/0 00:00:00 bash
5261 pts/0 00:00:00 ps
![Page 7: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/7.jpg)
UNIX> ps –u root | head –n 5
PID TTY TIME CMD
1 ? 00:00:01 init
2 ? 00:00:00 kthreadd
3 ? 00:00:00 migration/0
4 ? 00:00:00 ksoftirqd/0
![Page 8: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/8.jpg)
‣ kill terminates one or more processes ‣ sends SIGTERM signal to process (default) ‣ Command line argument(s) specify PID(s) to kill
UNIX> ./runaway & [1] 5177
UNIX> kill 5177
![Page 9: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/9.jpg)
UNIX> ./runaway & [1] 5282
UNIX> kill 5282
UNIX> ps | grep runaway [1]+ Terminated ./runaway
![Page 10: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/10.jpg)
‣ -9 option is more “forceful” kill ‣ sends SIGKILL signal to process ‣ SIGKILL cannot be blocked!
UNIX> ./super_runaway & [1] 5455
UNIX> kill -9 5455
![Page 11: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/11.jpg)
‣ pkill takes CMD instead of PID
UNIX> ./runaway & [1] 5350
UNIX> pkill runaway [1]+ Terminated ./runaway
![Page 12: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/12.jpg)
‣ top displays real-time information about current tasks ‣ top is a very powerful command line tool ‣ by default, top refreshes every 3 seconds ‣ top displays CPU, cache, memory, swap space,
virtual memory, runtimes, commands, etc. UNIX> top ‘q’ to quit..
![Page 13: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/13.jpg)
‣ See lecture notes for details:
‣ http://mcs.mines.edu/Courses/csci298/Content/process.html
![Page 14: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/14.jpg)
‣ While top is running, hit ‘d’ to specify delay time between updates
‣ Default delay is 3 seconds
‣ Change delay time to 0.5 seconds:
(zoomed in screen shot)
![Page 15: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/15.jpg)
‣ While top is running, hit ‘u’ to specify user
‣ Default is ALL users
‣ Change user to mrubin:
(zoomed in screen shots)
![Page 16: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/16.jpg)
‣ -u command line option to specify user
‣ select user BEFORE top begins
UNIX> top –u mrubin
![Page 17: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/17.jpg)
‣ nohup runs a command immune to hangups – process continues even after logging out!
‣ nohup does not output to a tty (terminal) – output appended to nohup.out
‣ very useful for running large jobs – e.g., a simulation that takes hours or days to run
![Page 18: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/18.jpg)
‣ E.g., process that prints “HELLO THERE” to stdout every second
UNIX> ssh someMachine
UNIX> ./sleep_print.sh
HELLO THERE
HELLO THERE
<CTRL-C>
UNIX>
![Page 19: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/19.jpg)
‣ run in background and without hangups (nohup)
UNIX> nohup ./sleep_print.sh &
[1] 5594
nohup: ignoring input and appending output to `nohup.out’
UNIX> wc –l nohup.out
4
![Page 20: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/20.jpg)
UNIX> exit UNIX> ssh someMachine UNIX> ps -u qhan| grep sleep_print.sh 5594 ? 00:00:00 sleep_print.sh UNIX> pkill sleep_print.sh UNIX> wc –l nohup.out 25 nohup.out
![Page 21: ps, kill, pkill, top, nohup - Oregon State Universityweb.engr.oregonstate.edu/~rubinma/Mines_274/Content/.../11_process… · UNIX> ps PID TTY TIME CMD 5184 pts/0 00:00:00 bash 5215](https://reader030.vdocument.in/reader030/viewer/2022021509/5b0c534f7f8b9a2f788c0541/html5/thumbnails/21.jpg)
‣ http://eecs.mines.edu/Courses/csci274/Assignments/11_processes.html
‣ Practice, practice, practice
init
do you get this?