Skip to main content

Running recurring jobs with scrontab

How to schedule jobs with SLURM

 Using `scrontab` with SLURM: Periodic Job Scheduling

In SLURM, `scrontab` is a tool that allows users to schedule **periodic jobs** using a familiar cron-like syntax. This is useful for automating recurring SLURM job submissions, such as daily simulations, log checks, or cleanup tasks.

---

##  What Is `scrontab`?

`scrontab` is SLURM's periodic scheduling system, similar to Unix `crontab`. It schedules recurring executions of SLURM jobs by submitting them through `sbatch`.

To use `scrontab`, your SLURM system must have periodic scheduling enabled (`EnablePeriodicJobSubmit` in `slurm.conf`) and accounting via `slurmdbd`.

---

##  Basic Usage Pattern

- Use `sbatch` in the **scrontab file** to submit a SLURM batch script.
- The **SLURM batch script** defines the job details and execution logic.
- Do **not** put `sbatch` inside your batch script.

---

## Example 1: Run a Job Daily at 3:30 AM

### 1. SLURM Batch Script (`daily_job.sh`)

```bash
#!/bin/bash
#SBATCH --job-name=dailyjob
#SBATCH --output=dailyjob.out
#SBATCH --time=00:10:00
#SBATCH --mem=1G

# Your job logic here
python /home/user/scripts/daily_task.py

2. Scrontab File (daily.scron)

30 3 * * * sbatch /home/user/daily_job.sh

3. Install the Scrontab

scrontab daily.scron

```