Scheduled tasks (cron): Difference between revisions

From HPCwiki
Jump to navigation Jump to search
Haars001 (talk | contribs)
No edit summary
IA migration §8: rewrite around scrontab (SLURM cron); discourage login-node crontab; fix crontab -l/-e bug (via update-page on MediaWiki MCP Server)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Recurring, scheduled tasks on Anunna should be run through the scheduler with '''scrontab''', SLURM's built-in cron. scrontab uses the familiar crontab syntax, but runs each scheduled task as a SLURM job on a compute node — so your recurring work gets proper resources and does not load the shared login nodes.


== Using crontab ==
{{Warning|Do not use a plain login-node <code>crontab</code> for recurring work. Anything scheduled with <code>crontab</code> runs on the login node, which is a shared access point not meant for computation, and the crontab is wiped when the login node reboots. Use <code>scrontab</code> instead.}}


With crontab you can run jobs on a fixed time schedule.
== Using scrontab ==
This means that you can e.g. download some data every day.


To start an edit use '''crontab -l''' , the info on how that file should look can be found by using '''man 5 crontab'''.
Edit your scrontab with:


Be aware of the following :
<syntaxhighlight lang="bash">
scrontab -e
</syntaxhighlight>


The scripts will run on the login node, so do not use a lot of resources.
Each entry has two parts: one or more <code>#SCRON</code> lines that set the SLURM options for the job (partition, time limit, resources, job name, …), followed by a normal crontab time specification and the command to run.
The crontab entry will be wiped upon reboot !
 
<syntaxhighlight lang="bash">
#SCRON --partition=main
#SCRON --time=00:10:00
#SCRON --job-name=daily-download
0 2 * * * /home/<group>/<username>/scripts/download.sh
</syntaxhighlight>
 
This runs <code>download.sh</code> as a SLURM job every day at 02:00. List your current entries with:
 
<syntaxhighlight lang="bash">
scrontab -l
</syntaxhighlight>
 
The crontab time format (the <code>0 2 * * *</code> part) is described in the crontab manual page:
 
<syntaxhighlight lang="bash">
man 5 crontab
</syntaxhighlight>
 
== See also ==
* [[Batch Jobs]]
* [[Scheduler Overview (Slurm)]]

Latest revision as of 12:58, 18 June 2026

Recurring, scheduled tasks on Anunna should be run through the scheduler with scrontab, SLURM's built-in cron. scrontab uses the familiar crontab syntax, but runs each scheduled task as a SLURM job on a compute node — so your recurring work gets proper resources and does not load the shared login nodes.

 ⚠️ Warning: Do not use a plain login-node crontab for recurring work. Anything scheduled with crontab runs on the login node, which is a shared access point not meant for computation, and the crontab is wiped when the login node reboots. Use scrontab instead.

Using scrontab

Edit your scrontab with:

scrontab -e

Each entry has two parts: one or more #SCRON lines that set the SLURM options for the job (partition, time limit, resources, job name, …), followed by a normal crontab time specification and the command to run.

#SCRON --partition=main
#SCRON --time=00:10:00
#SCRON --job-name=daily-download
0 2 * * * /home/<group>/<username>/scripts/download.sh

This runs download.sh as a SLURM job every day at 02:00. List your current entries with:

scrontab -l

The crontab time format (the 0 2 * * * part) is described in the crontab manual page:

man 5 crontab

See also