Search code examples
cluster-computingsnakemake

How do I use snakemake --cluster-cancel?


I currently have a snakemake pipeline running with multiple jobs on a cluster. I want to cancel my jobs early, and the snakemake documentation says that I can use the --cluster-cancel option. However, it doesn't have any example of how to use it. The cluster I am using cancels jobs with qdel. So, I tried using snakemake --cluster-cancel "qdel", but when I do this it returns the error

snakemake: error: unrecognized arguments: --cluster-cancel


Solution

  • Make sure you are using snakemake >= v7.0.0.

    Then set --cluster-cancel qdel or--cluster-cancel scancel depending on whether the job scheduling system is PBS or SLURM.

    You can also set this in the config.yaml as cluster-cancel: qdel etc.

    If you use SLURM, you must add the --parsable flag to the sbatch command passed via --cluster.

    This is an example config.yaml for SLURM:

    cluster: "sbatch --time={cluster.time} --cpus-per-task={cluster.n} --parsable"
    cluster-cancel: scancel
    

    Related question: "scancel: error: Invalid job id Submitted batch job" with --cluster-cancel from snakemake