Submitting Jobs
Exercises¶
- Submit with a custom output filename
Write a short job script that runs echo "Hello from $HOSTNAME". Use the --output directive to write output to logs/%x_%j.out (job name + job ID). Remember to create the logs/ directory first.
Hint / Solution
- Use --wrap for a one-liner
Submit a quick job using --wrap that prints the current date and the contents of /proc/cpuinfo | head -5. Request 5 minutes and 1G of memory on the command line.
- Set up email notifications
Modify a job script (or use command-line flags) to send you an email when the job begins, ends, or fails. Submit it and verify the directives with scontrol show job.
Hint / Solution
- Pass arguments to a job script
Create a job script called greet.sh that accepts two positional arguments: a name ($1) and a project ($2). Have it print "Hello, [name]! Working on [project]." Submit it with arguments.
Hint / Solution
- Use --chdir to control the working directory
Create a directory called /tmp/$USER/test_chdir. Submit a job that uses --chdir to set the working directory to that path. Inside the script, run pwd to confirm the job started in the right directory.