Skip to content

Commit 58e0ed2

Browse files
lukeseawalkersean-smith
authored andcommitted
Add tutorial for AWS Batch first job submission
Signed-off-by: Luca Carrogu <[email protected]>
1 parent 79d9162 commit 58e0ed2

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

docs/source/hello_world.rst

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,69 @@ Here, we see our job script, an "e1" and "o1" file. Since the e1 file is empty,
102102
Hello World from ip-192-168-1-125
103103

104104
We can see that our job successfully ran on instance "ip-192-168-1-125".
105+
106+
Running your first job using AWS Batch
107+
======================================
108+
Now we'll create a simple job which sleeps for a little while and then outputs it's own hostname, greeting the name passed as parameter.
109+
110+
Create a file called "hellojob.sh" with the following contents. ::
111+
112+
#!/bin/bash
113+
sleep 30
114+
echo "Hello $1 from $(hostname)"
115+
116+
Next, submit the job using :code:`awsbsub` and ensure it runs. ::
117+
118+
$ awsbsub -jn hello -cf hellojob.sh Luca
119+
Job 6efe6c7c-4943-4c1a-baf5-edbfeccab5d2 (hello) has been submitted.
120+
121+
Now, you can view your queue and check the status of the job. ::
122+
123+
$ awsbstat
124+
jobId jobName status startedAt stoppedAt exitCode
125+
------------------------------------ ----------- -------- ------------------- ----------- ----------
126+
6efe6c7c-4943-4c1a-baf5-edbfeccab5d2 hello RUNNING 2018-11-12 09:41:29 - -
127+
128+
You can even see the detailed information for the job. ::
129+
130+
$ awsbstat 6efe6c7c-4943-4c1a-baf5-edbfeccab5d2
131+
jobId : 6efe6c7c-4943-4c1a-baf5-edbfeccab5d2
132+
jobName : hello
133+
createdAt : 2018-11-12 09:41:21
134+
startedAt : 2018-11-12 09:41:29
135+
stoppedAt : -
136+
status : RUNNING
137+
statusReason : -
138+
jobDefinition : parallelcluster-myBatch:1
139+
jobQueue : parallelcluster-myBatch
140+
command : /bin/bash -c 'aws s3 --region us-east-1 cp s3://parallelcluster-mybatch-lui1ftboklhpns95/batch/job-hellojob_sh-1542015680924.sh /tmp/batch/job-hellojob_sh-1542015680924.sh; bash /tmp/batch/job-hellojob_sh-1542015680924.sh Luca'
141+
exitCode : -
142+
reason : -
143+
vcpus : 1
144+
memory[MB] : 128
145+
nodes : 1
146+
logStream : parallelcluster-myBatch/default/c75dac4a-5aca-4238-a4dd-078037453554
147+
log : https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logEventViewer:group=/aws/batch/job;stream=parallelcluster-myBatch/default/c75dac4a-5aca-4238-a4dd-078037453554
148+
-------------------------
149+
150+
The job is currently in a RUNNING state. Wait 30 seconds for the job to finish and run :code:`awsbstat` again. ::
151+
152+
$ awsbstat
153+
jobId jobName status startedAt stoppedAt exitCode
154+
------------------------------------ ----------- -------- ------------------- ----------- ----------
155+
156+
You can see that the job is in the SUCCEEDED status. ::
157+
158+
$ awsbstat -s SUCCEEDED
159+
jobId jobName status startedAt stoppedAt exitCode
160+
------------------------------------ ----------- --------- ------------------- ------------------- ----------
161+
6efe6c7c-4943-4c1a-baf5-edbfeccab5d2 hello SUCCEEDED 2018-11-12 09:41:29 2018-11-12 09:42:00 0
162+
163+
Now that there are no jobs in the queue, we can check for output through the :code:`awsbout` command. ::
164+
165+
$ awsbout 6efe6c7c-4943-4c1a-baf5-edbfeccab5d2
166+
2018-11-12 09:41:29: Starting Job 6efe6c7c-4943-4c1a-baf5-edbfeccab5d2
167+
download: s3://parallelcluster-mybatch-lui1ftboklhpns95/batch/job-hellojob_sh-1542015680924.sh to tmp/batch/job-hellojob_sh-1542015680924.sh
168+
2018-11-12 09:42:00: Hello Luca from ip-172-31-4-234
169+
170+
We can see that our job successfully ran on instance "ip-172-31-4-234".

0 commit comments

Comments
 (0)