{"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":"<!-- shortcode-right-column -->\n<div class=\"shortcode-right-column\" >\n    <div class=\"shortcode-right-column__container\"><\/p>\n<p><!-- shortcode-contact -->\n<div class=\"shortcode-contact\">\n    <div class=\"contact-header\">\n        <h3>Contact Advanced Research Computing<\/h3>\n    <\/div>\n    <div class=\"contact-body\">\n                <a href=\"mailto:ask-arc@nau.edu\" aria-label=\"Contact Advanced Research Computing: Email Address\" title=\"Email Address\">\n            <div class=\"contact-icon-container\">\n                <i class=\"fas fa-envelope\" aria-hidden=\"true\"><\/i>\n                <span class=\"sr-only\">Email:<\/span>\n            <\/div>\n            <div class=\"contact-email\">ask-arc&#8203;@nau.edu<\/div>\n        <\/a>\n                    <\/div>\n<\/div>\n\n<\/p>\n<hr \/>\n<h4>Quick Links<\/h4>\n<ul>\n<li><a href=\"https:\/\/in.nau.edu\/hpc\/request-storage\/\">Request Storage<\/a><\/li>\n<li><a href=\"https:\/\/in.nau.edu\/hpc\/overview\/using-the-cluster-introduction\/\">Using the Cluster: Introduction<\/a><\/li>\n<li><a href=\"https:\/\/in.nau.edu\/hpc\/overview\/using-the-cluster-advanced\/\">Using the Cluster: Advanced<\/a><\/li>\n<li><a href=\"https:\/\/in.nau.edu\/hpc\/faqs\/\">FAQs<\/a><\/li>\n<\/ul>\n<hr \/>\n<p><\/div>\n<\/div>\n\n<h1>Submitting Your First Job<\/h1>\n<p>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<p>A SLURM job script is a bash shell script with special comments starting with <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">#SBATCH<\/span>. View example job scripts in <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">\/common\/contrib\/examples\/job_scripts<\/span>.<\/p>\n<pre><code>[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<p>Take note of the first line of the script:<\/p>\n<pre><code>#!\/bin\/bash<\/code><\/pre>\n<p>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 style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">#<\/span> is a comment and is therefore disregarded when the script is running.<\/p>\n<p><strong>However,<\/strong> in this context, any line that begins with <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">#SBATCH<\/span> is actually a meta-command to the &#8220;Slurm&#8221; scheduler that informs it how to prioritize, schedule, and place your job. The <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">&#8211;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<p>The last three lines are the &#8220;payload&#8221; (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<p><strong>Now lets submit the job to the cluster:<\/strong><\/p>\n<pre><code>[abc123@wind ~ ]$ sbatch simplejob.sh\r\nSubmitted batch job 138405<\/code><\/pre>\n<p>Slurm responds back by providing you a job number <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">138405<\/span>.\u00a0 You can use this job number to monitor your jobs progress.<\/p>\n<p><strong>Lets look for job <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">138405<\/span> in the queue:<\/strong><\/p>\n<pre><code>[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<p>We can see that our job is in the running state residing in the <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">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 <span style=\"font-size: 16px; font-family: monospace; border: 1px solid; border-radius: 4px; padding: 0px 4px 0px; border-color: #BBBBBB;\">\/scratch\/nauid\/output.txt<\/span>.<\/p>\n<pre><code>[abc123@wind ~ ]$ cat \/scratch\/nauid\/output.txt\r\nSleeping for 30 seconds ...\r\nAll refreshed now<\/code><\/pre>\n<p>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":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":76,"featured_media":145,"parent":49,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","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}]}}