{"id":66,"date":"2018-01-16T19:54:44","date_gmt":"2018-01-16T19:54:44","guid":{"rendered":"https:\/\/in.nau.edu\/hpc\/?page_id=66"},"modified":"2024-08-13T14:51:05","modified_gmt":"2024-08-13T21:51:05","slug":"submitting-your-first-job","status":"publish","type":"page","link":"https:\/\/in.nau.edu\/arc\/overview\/submitting-your-first-job\/","title":{"rendered":"Submitting your First Job"},"content":{"rendered":"\n
\n
<\/div>\n<\/div>\n\n
In order to submit work to the cluster we must first put together a job script which tells Slurm what resources you require for your application. In addition to resources, we need to tell Slurm what command or application to run.<\/p>\n
A SLURM job script is a bash shell script with special comments starting with #SBATCH<\/span>. View example job scripts in \/common\/contrib\/examples\/job_scripts<\/span>.<\/p>\n Take note of the first line of the script:<\/p>\n This line signifies that this file is a bash script\u00a0 As you might already know, any line in a bash script that begins with a #<\/span> is a comment and is therefore disregarded when the script is running.<\/p>\n However,<\/strong> in this context, any line that begins with #SBATCH<\/span> is actually a meta-command to the “Slurm” scheduler that informs it how to prioritize, schedule, and place your job. The –time<\/span> command allows you to give SLURM a maximum amount of time that your job will be allowed to run. This is very important for scheduling your jobs efficiently because the shorter the time you provide, the sooner your job will start.<\/p>\n The last three lines are the “payload” (the work being done). In this case our job is simply printing a message, sleeping for 30 seconds (pretending to do something) and then coming back from sleep and printing a final message.<\/p>\n Now lets submit the job to the cluster:<\/strong><\/p>\n Slurm responds back by providing you a job number 138405<\/span>.\u00a0 You can use this job number to monitor your jobs progress.<\/p>\n Lets look for job 138405<\/span> in the queue:<\/strong><\/p>\n We can see that our job is in the running state residing in the all<\/span> queue with the work being done on the node: wind. Now that the job is running we can inspect its output by viewing the output file that we specified in our job script \/scratch\/nauid\/output.txt<\/span>.<\/p>\n Great, the output that normally would have been printed to the screen has been captured in the output file that we specified in our jobscript.<\/p>\n","protected":false},"excerpt":{"rendered":" Submitting Your First Job In order to submit work to the cluster we must first put together a job script which tells Slurm what resources you require for your application. In addition to resources, we need to tell Slurm what command or application to run. A SLURM job script is a bash shell script with […]<\/p>\n","protected":false},"author":76,"featured_media":145,"parent":49,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ring_central_script_selection":"","footnotes":""},"class_list":["post-66","page","type-page","status-publish","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/66","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/users\/76"}],"replies":[{"embeddable":true,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/comments?post=66"}],"version-history":[{"count":15,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/66\/revisions"}],"predecessor-version":[{"id":3577,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/66\/revisions\/3577"}],"up":[{"embeddable":true,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/pages\/49"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/media\/145"}],"wp:attachment":[{"href":"https:\/\/in.nau.edu\/arc\/wp-json\/wp\/v2\/media?parent=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}[abc123@wind ~ ]$ cat \/common\/contrib\/examples\/job_scripts\/simplejob.sh\r\n#!\/bin\/bash\r\n# the name of your job\r\n#SBATCH --job-name=test\r\n# this is the file your ourput and errors go to\r\n#SBATCH --output=\/scratch\/nauid\/output.txt\r\n# 20 min, this is the MAX time your job will run\r\n#SBATCH --time=20:00\r\n# your work directory\r\n#SBATCH --workdir=\/scratch\/nauid\r\n# change this ater you determine your process is sane\r\n\r\necho \"Sleeping fof 30 seconds...\"\r\nsleep 30\r\necho \"All refreshed now!\"<\/code><\/pre>\n#!\/bin\/bash<\/code><\/pre>\n[abc123@wind ~ ]$ sbatch simplejob.sh\r\nSubmitted batch job 138405<\/code><\/pre>\n[abc123@wind ~ ]$ squeue\r\n JOBID PARTITION \u00a0NAME USER ST TIME\u00a0 NODES NODELIST(REASON)\r\n138405 core\u00a0 test abc123\u00a0 R \u00a00:05\u00a0\u00a0\u00a0\u00a0\u00a0 1 wind<\/code><\/pre>\n[abc123@wind ~ ]$ cat \/scratch\/nauid\/output.txt\r\nSleeping for 30 seconds ...\r\nAll refreshed now<\/code><\/pre>\n