Difference between revisions of "Interactive jobs on cluster"
Line 1: | Line 1: | ||
− | When using cluster it is important to know how to manage interactive jobs. We may want to know what all jobs are running, what all jobs a particular user is running and how to kill a particular job. The following bash commands are useful for |
+ | When using cluster it is important to know how to manage interactive jobs. We may want to know what all jobs are running, what all jobs a particular user is running and how to kill a particular job. The following bash commands are useful for this purpose: top, ps and kill. |
===top=== |
===top=== |
||
Line 15: | Line 15: | ||
ps stands for process status. One of its use can be to view the jobs of a particular user. |
ps stands for process status. One of its use can be to view the jobs of a particular user. |
||
<pre> ps aux | egrep CRSid </pre> |
<pre> ps aux | egrep CRSid </pre> |
||
− | + | <b> ps aux </b> displays all processes along with usernames and <b> egrep CRSid </b> can be used to extract processes belonging to a particular user. |
|
− | |||
===kill=== |
===kill=== |
||
kill can be used to kill a process. When running an interactive job, its execution can be stopped by pressing <b>Ctrl+z</b> and then kill command can be used. |
kill can be used to kill a process. When running an interactive job, its execution can be stopped by pressing <b>Ctrl+z</b> and then kill command can be used. |
Revision as of 11:08, 18 May 2020
When using cluster it is important to know how to manage interactive jobs. We may want to know what all jobs are running, what all jobs a particular user is running and how to kill a particular job. The following bash commands are useful for this purpose: top, ps and kill.
top
top command is used to list the processes running on the system in real time. To exit from the top window press q . top command has several useful options.
- top -u CRSid is used to list the jobs of a particular user
- top -n 1 -b > output can be used to save the top window to a file
In top window itself
- pressing z highlights the running process
- pressing c shows absolute path of all running processes
- pressing k displays a line in top window where the process id (pid) of the process that needs to be killed can be directly entered and when asked about confirmation simply press y to kill the process.
- pressing Shift+o opens a new window with several options along with the corresponding letter that needs to be pressed to sort the top window based on a particular column. For example to sort all processes depending on memory usage i.e. %MEM press shift+o, n and Enter .
There is a lot more that can be done using top and more information can be found on its man page.
ps
ps stands for process status. One of its use can be to view the jobs of a particular user.
ps aux | egrep CRSid
ps aux displays all processes along with usernames and egrep CRSid can be used to extract processes belonging to a particular user.
kill
kill can be used to kill a process. When running an interactive job, its execution can be stopped by pressing Ctrl+z and then kill command can be used.
kill signal pid
kill -9 pid can be used to kill the process immediately. The option -9 stands for SIGKILL. More information about different types of signals can be found here https://en.wikipedia.org/wiki/Signal_(IPC)#List_of_signals