{"id":181,"date":"2018-09-04T17:13:55","date_gmt":"2018-09-04T16:13:55","guid":{"rendered":"http:\/\/ri.itservices.manchester.ac.uk\/csf3\/?page_id=181"},"modified":"2025-05-22T15:54:57","modified_gmt":"2025-05-22T14:54:57","slug":"q-commands","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/batch\/q-commands\/","title":{"rendered":"SGE Batch commands (qsub, qstat, qdel, qacct)"},"content":{"rendered":"<p><script type=\"text\/javascript\">\n    function toggle() {\n        var x = document.getElementById(\"hidetext\");\n        if (x.style.display === \"none\") {x.style.display = \"block\";}\n        else {x.style.display = \"none\";}\n    }\n<\/script><\/p>\n<div class=\"warning\">The SGE batch system has been shutdown and the CSF upgraded to use the Slurm batch system. Please read the <a href=\"\/csf3\/batch-slurm\">CSF3 Slurm documentation<\/a> instead.<\/p>\n<p>To display this old SGE page, <a href=\"javascript:toggle()\">click here<\/a>\n<\/div>\n<div id=\"hidetext\" style=\"display: none\">\n<h2>Batch Commands<\/h2>\n<p>Your applications should be run in the batch system. You\u2019ll need a <em>jobscript<\/em> (a plain text file) describing your job &#8211; its CPU, memory and possibly GPU requirements, and also the commands you actually want the job to run.<\/p>\n<p>Further details on how to write jobscripts are in the sections on <a href=\"\/csf3\/batch\/serial-jobs\">serial jobs<\/a>, <a href=\"\/csf3\/batch\/parallel-jobs\">parallel jobs<\/a>, <a href=\"\/csf3\/batch\/job-arrays\/\">job-arrays<\/a> and <a href=\"\/csf3\/batch\/gpu-jobs\/\">GPU jobs<\/a>.<\/p>\n<p>You\u2019ll then use one or more of the following batch system commands to <em>submit<\/em> your job to the system and check on its status. These commands should be run from the CSF&#8217;s login nodes:<\/p>\n<dl>\n<dt id=\"qsub\"><code>qsub <em>jobscript<\/em><\/code><\/dt>\n<dd>Submit a job to the batch system, usually by submitting a <em>jobscript<\/em>. Alternatively you can specify job options on the <code>qsub<\/code> command-line. We recommend using a jobscript because this allows you to easily reuse your jobscript every time you want to run the job. Remembering the command-line options you used (possibly months ago) is much more difficult.<\/p>\n<p>The <code>qsub<\/code> command will return a unique job-ID number if it accepts the job. You can use this in other commands (see below) and, when requesting support about a job, you should include this number in the details you send in.<\/p>\n<p>For example, when submitting a job you will see a message similar to:<\/p>\n<pre>\r\n[mabcxyz1@hlogin2 [csf3] ~]$ <strong>qsub <em>myjobscript<\/em><\/strong>\r\nYour job 12345 (\"<em>myjobscript<\/em>\") has been submitted\r\n<\/pre>\n<p>For scripting purposes, you may prefer just to receive the jobid number from the <code>qsub<\/code> command. Add the <code>-terse<\/code> flag to achieve this:<\/p>\n<pre>\r\nqsub <strong>-terse<\/strong> <em>myjobscript<\/em>\r\n12345\r\n<\/pre>\n<\/dd>\n<dt id=\"qstat\"><code>qstat<\/code><\/dt>\n<dd>Report the current status of <em>your<\/em> jobs in the batch system (queued\/waiting, running, in error, finished). Note that if you see no jobs listed when you run <code>qstat<\/code> it means you have no jobs in the system &#8211; they have all finished or you haven&#8217;t submitted any!<\/p>\n<p>Some examples:<\/p>\n<p>In this example <code>qstat<\/code> returns <em>no output<\/em> which means you have <em>no jobs<\/em> in the queue, either running or waiting:<\/p>\n<pre>\r\n[mabcxyz1@hlogin2 [csf3] ~]$ <strong>qstat<\/strong>\r\n[mabcxyz1@hlogin2 [csf3] ~]$\r\n<\/pre>\n<p>In this example <code>qstat<\/code> shows we have two jobs running (one using 1 core, the other using 28 cores) and one job waiting (it will use 16 cores when it runs.):<\/p>\n<pre>\r\n[mabcxyz1@hlogin2 [csf3] ~]$ <strong>qstat<\/strong>\r\njob-ID prior  name    user     state submit\/start at    queue                slots ja-task\r\n------------------------------------------------------------------------------------------\r\n10281 0.40000 chemsim mabcxyz1  r    10\/26\/2018 10:31:02 ser&#105;&#97;&#108;&#x2e;&#x71;&#x40;&#x6e;&#x6f;&#x64;e78&#49;&#46;&#112;&#114;&#x69;  1\r\n10644 0.36474 fsolve  mabcxyz1  r    10\/31\/2018 14:08:21 &#x70;&#x61;&#114;&#97;l&#x6c;&#x65;&#x6c;&#46;&#113;&#64;&#x6e;&#x6f;&#x64;&#101;&#55;6&#x38;&#x2e;&#x70;  28\r\n10690 0.35467 fsolve  mabcxyz1  qw   10\/31\/2018 14:12:19                       16\r\n #               #              #             ###                              #\r\n #               #              #              #                               # Number of\r\n #               #              #              #                               # CPU cores\r\n #               #              #              #\r\n #               #              #              # If running: date &amp; time the job started\r\n #               #              #              # If waiting: date &amp; time job was submitted\r\n #               #              #\r\n #               #              # r   - job is running\r\n #               #              # qw  - job is queued waiting\r\n #               #              # Eqw - the jobscript has reported an error \r\n #               #\r\n #               # Usually the name of your jobscript\r\n #\r\n # Every job is given a unique job ID number\r\n # (<strong>please tell us this number if requesting support<\/strong>)\r\n<\/pre>\n<p>For more information about monitoring jobs, including how to monitor GPU jobs, please see the <a href=\"\/csf3\/batch\/job-monitoring\/\">job monitoring page<\/a>.\n<\/dd>\n<\/dl>\n<p>The following commands are used less frequently but can still be run if you need to:<\/p>\n<dl>\n<dt id=\"qdel\"><code>qdel <em>jobid<\/em><\/code><\/dt>\n<dd>To remove <em>your<\/em> job from the batch system early, either to terminate a running job before it finishes or to simply remove a queued job before it has started running.<\/p>\n<p>Also use this if your job goes in to an error state or you decide you don&#8217;t want a job to run.<\/p>\n<p>Note that if your job is in the <code>Eqw<\/code> state, <strong>please leave it in the queue if requesting support<\/strong>. It is easier for us to diagnose the error if we can see the job. We may ask you to <code>qdel<\/code> the job once we have looked at it &#8211; there is usually no way to fix an existing job.<\/p>\n<p>For example, maybe you realise you&#8217;ve given a job the wrong input parameters causing it to produce junk results. You don&#8217;t need to leave it running to completion (which might be hours or days). Instead you can <em>kill<\/em> the job using qdel. You need to know the job-ID number of the job:<\/p>\n<pre>\r\n[mabcxyz1@hlogin1 [csf3] ~]$ <strong>qdel <em>12345<\/em><\/strong>\r\nmabcxyz1 has registered the job <em>12345<\/em> for deletion\r\n<\/pre>\n<p>The job will eventually be deleted (it may take a minute or two for this to happen). Use <code>qstat<\/code> to check your list of jobs.<\/p>\n<p>Please also see the <a href=\"\/csf3\/batch\/job-arrays\/#Deleting_Job_Arrays\">Deleteing Job Arrays<\/a> notes.\n<\/dd>\n<dt id=\"qacct\"><code>qacct -j <em>jobid<\/em><\/code><\/dt>\n<dd>Advanced users. Once your job has finished you can use this command to get a summary of information for wall-clock time, max memory consumption and exit status amongst many other statistics about the job. This is useful for diagnosing why a job failed.<\/dd>\n<dt><code>qalter <em>options<\/em><\/code><\/dt>\n<dd>Advanced users, not a recommended command. It <em>may<\/em> be possible to modify a job that is waiting in the queue (e.g., if you forgot to request a high-memory node you could add that option without deleting the job and resubmitting it). However, we recommend that, if you think your job is incorrectly described by the jobscript, you should delete the job from the queue, fix the jobscript and resubmit it. It is much better to have an accurate jobscript that documents how you ran a job and allows you to rerun the job in future.<\/dd>\n<\/dl>\n<h2>Further Information<\/h2>\n<p>Our own documentation throughout this site provides lots of examples of writing jobscripts and how to submit jobs. SGE also comes with a set of comprehensive <em>man pages<\/em>. Some of the most useful ones are:<\/p>\n<ul>\n<li><code>man qsub<\/code><\/li>\n<li><code>man qstat<\/code><\/li>\n<li><code>man qdel<\/code><\/li>\n<li><code>man qacct<\/code><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The SGE batch system has been shutdown and the CSF upgraded to use the Slurm batch system. Please read the CSF3 Slurm documentation instead. To display this old SGE page, click here Batch Commands Your applications should be run in the batch system. You\u2019ll need a jobscript (a plain text file) describing your job &#8211; its CPU, memory and possibly GPU requirements, and also the commands you actually want the job to run. Further details.. <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/batch\/q-commands\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":22,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-181","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/comments?post=181"}],"version-history":[{"count":20,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/181\/revisions"}],"predecessor-version":[{"id":10076,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/181\/revisions\/10076"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/22"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/media?parent=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}