Overview
The scrontab command in Slurm allows users to schedule recurring batch jobs, similar to the traditional cron utility. This tool enables the automation of tasks at specified intervals, leveraging Slurm’s workload management capabilities.
Notice: ARC does not monitor the state of scrontab jobs. Users are responsible for managing and ensuring the proper execution of their scheduled tasks.
Creating and using scrontab
Edit your crontab (this will use vim by default)
scrontab -eWhen you save your script, Slurm will automatically schedule it to run at the specified interval. By default, it uses the text editor vim. To change it, update the environmental variable EDITOR to your preferred editor.
When setting times for tasks, it's often easiest to use standard cron time intervals like @hourly or @daily to indicate when you want your job to run. For example:
@daily /path/to/your/script.shIf you need a specific time, you can specify it using the standard cron format:
* * * * * commandThe five asterisks represent the following time fields:
1. Minute: (0-59)
2. Hour: (0-23)
3. Day of Month: (1-31)
4. Month: (1-12 or names)
5. Day of Week: (0-7, where both 0 and 7 represent Sunday, or names)
For example, to run a script every day at 3:30 AM:
30 3 * * * /path/to/your/script.shExample scrontab script
This scrontab script specifies the account, partition, and duration the job is expected to run. It will be eligible to run at midnight every day and will append the output of each job to a file named output-XXXXX.out (where XXXXX is the Slurm job ID).
#SCRON -A <account>
#SCRON -p standard
#SCRON -t 00:30:00
#SCRON -J sc_test
#SCRON -o output-%j.out
#SCRON --open-mode=append
@daily $HOME/scripts/your_script.shMonitoring and Managing `scrontab` Jobs
To view your current `scrontab` entries
scrontab -lTo remove your `scrontab` entries (currently running jobs will continue to run)
scrontab -r To monitor your scheduled jobs, use the squeue command (list all jobs in the queue including those scheduled via scrontab)
squeue -u $USERFor more detailed information on scrontab, refer to the official Slurm documentation: https://slurm.schedmd.com/scrontab.html
Note: As previously mentioned, ARC does not monitor the state of scrontab jobs. It is the user’s responsibility to manage and verify the execution of their scheduled tasks.
