Difference between revisions of "Interactive jobs on cluster"

From Docswiki
Jump to navigation Jump to search
(Created page with "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...")
 
Line 2: Line 2:
   
 
===top===
 
===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
+
<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.
* top -u CRSid 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
* top -n 1 -b > output 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 z highlights the running process
+
* pressing <b>z </b> highlights the running process
* pressing c shows absolute path of all running processes
+
* pressing <b>c </b> 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
+
* 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 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.
+
* 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>.
 
There is a lot more that can be done using top and more information can be found on its man page.
 
There is a lot more that can be done using top and more information can be found on its man page.
   
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>
The a, u and x in aux stand for displaying all processes along with usernames and x stands for displaying even those processes not necessarily
+
The a, u and x in aux stand for displaying all processes along with usernames from which processes of a particular user can be extracted using egrep.
   
 
===kill===
 
===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 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.
 
<pre>
 
<pre>
 
kill signal pid
 
kill signal pid
 
</pre>
 
</pre>
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
+
<b> kill -9 pid </b>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

Revision as of 11:05, 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 the 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 

The a, u and x in aux stand for displaying all processes along with usernames from which processes of a particular user can be extracted using egrep.

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