Difference between revisions of "Interactive jobs on cluster"
Line 3: | Line 3: | ||
===top=== |
===top=== |
||
<b>top </b> command is used to list the processes running on the system in real time. To exit from the top window press <b>q</b> . top command has several useful options. |
<b>top </b> command is used to list the processes running on the system in real time. To exit from the top window press <b>q</b> . top command has several useful options. |
||
− | * <b>top -u CRSid </b> is used to list the jobs of a particular user |
+ | * <b>top -u CRSid </b> is used to list the jobs of a particular user. |
− | * <b> top -n 1 -b > output </b> can be used to save the top window to a file |
+ | * <b> top -n 1 -b > output </b> can be used to save the top window to a file. |
In top window itself |
In top window itself |
||
− | * pressing <b>z </b> highlights the running process |
+ | * pressing <b>z </b> highlights the running process. |
− | * pressing <b>c </b> shows absolute path of all running processes |
+ | * pressing <b>c </b> shows absolute path of all running processes. |
* pressing <b>k </b> 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 <b>y </b> to kill the process. |
* pressing <b>k </b> 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 <b>y </b> to kill the process. |
||
* pressing <b>Shift+o </b> 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 <b> shift+o, n </b> and <b> Enter </b>. |
* pressing <b>Shift+o </b> 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 <b> shift+o, n </b> and <b> Enter </b>. |
Latest revision as of 11:09, 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