Table of Contents
Jobs at regular intervals
If you have small tasks you want to run at regular intervals, Slurm has the scrontab utility available. It gives you a cron
-like interface for submitting and running batch jobs at regular intervals, e.g. monitoring tasks or housekeeping scripts.
Usage
Like cron
, Slurm uses a configuration file to define these recurring jobs. Each users has it's own configuartion file. The files are not edited dierctly, but instead you can use scrontab -e
to edit 1) your all your scrontab-jobs.
Inside the scrontab file, you can use #SCRON
to give instructions to the scheduler, similar to the #SBATCH
lines in normal jobscript, though not all options are supported. After the #SCRON
lines, you have one line to define when and what should be done, just like a normal cron job.
You have two styles of defining when you job should run:
- common time intervals, e.g.
@hourly
,@daily
,@weekly
The latter can get quite complex, but there are online tools out there to help you with it.
After defining when something should run, you can give a command or a script that is run at the appropriate time. The command or script has to be on the same line. The command to execute does not need to be a Slurm jobscript (i.e. should not contain #SBATCH
lines).
These #SCRON
lines and the following line comprise a single scrontab entry. All #SCRON
lines following will be counted towards the next command.
You can list your currently defined scron
jobs with scrontab -l
.
Slurm cannot guarantee that the jobs will run at the requested times, but tries to schedule it es close as possible. Internally, jobs are submitted to Slurm and set with a specific BeginTime. Once a scron
job ran, it will be requeued with a new BeginTime. These jobs will also show up in squeue
.
Example
#SCRON -p fat #SCRON -t 01:00:00 @daily /usr/users/mboden/update-database.sh #SCRON -p medium #SCRON -C scratch #SCRON -t 05:00 #check scratch every 5 minutes */15 * * * * /usr/users/mboden/check-scratch.sh
scrontab
uses the editor saved in the $EDITOR
variable.