<p>As noted by the comments and the SLURM manual (not so much bioinformatics related?)</p>

<p>You need the following terms in your batch/queuing command:</p>

<pre><code>--mail-type=ALL
--mail-user=you@email.com
</code></pre>

<p>I used "ALL" which will send you <em>all</em> reports. If you just want the finish message then you would use "END" and "FAIL" like such:</p>

<pre><code>--mail-type=END,FAIL
</code></pre>

<p>Here are the specifics from the <a href="https://slurm.schedmd.com/sbatch.html" rel="nofollow noreferrer">manual</a> if you wish to make a different selection:</p>

<p><strong>--mail-type=</strong></p>

<blockquote>
  <p>Notify user by email when certain event types occur. Valid type values
  are NONE, BEGIN, END, FAIL, REQUEUE, ALL (equivalent to BEGIN, END,
  FAIL, REQUEUE, and STAGE_OUT), STAGE_OUT (burst buffer stage out and
  teardown completed), TIME_LIMIT, TIME_LIMIT_90 (reached 90 percent of
  time limit), TIME_LIMIT_80 (reached 80 percent of time limit),
  TIME_LIMIT_50 (reached 50 percent of time limit) and ARRAY_TASKS (send
  emails for each array task). Multiple type values may be specified in
  a comma separated list. The user to be notified is indicated with
  --mail-user. Unless the ARRAY_TASKS option is specified, mail notifications on job BEGIN, END and FAIL apply to a job array as a
  whole rather than generating individual email messages for each task
  in the job array.</p>
</blockquote>

<p><strong>--mail-user=</strong></p>

<blockquote>
  <p>User to receive email notification of state changes as defined by
  --mail-type. The default value is the submitting user.</p>
</blockquote>

CC BY-SA 4.0
2019-03-15T14:09:51.257Z
2019-03-15T14:09:51.257Z
story
<p>I am working on a SLURM-based cluster. I am currently using the following slurm json file:</p>

<pre><code>{
    "__default__" :
    {
        "A" : "overall",
        "time" : "96:00:00",
        "nodes": 1,
        "ntasks": 1,
        "cpus" : 24,
        "p" : "LONG",
        "mem": 16G,
        "output": "snakemake%A.out",
        "error": "snakemake%A.err"
    }
}
</code></pre>

<p>along with the following command:</p>

<pre><code>snakemake --jobs 200 --use-conda --printshellcmds  --cluster-config slurm.json --cluster "sbatch -A {cluster.A} -p {cluster.p} -t {cluster.time} --output {cluster.output} --error {cluster.error} --ntasks {cluster.ntasks} --cpus-per-task {cluster.cpus} --mem {cluster.mem}"
</code></pre>

<p>I would like to be able to specify my email and receive an email when a job finishes. I have tried adding a line in the json file with <code>"email": my@email.com</code> and an option to the sbatch command <code>--email {cluster.email}</code> but that did not work.</p>

<p>Anyone knows how to do it?</p>

CC BY-SA 4.0
2019-03-11T23:13:33.057Z
After looking at some headers of files (`#SBATCH --mail-user=email@com`I have used `--mail-user` instead. I'll let you know if I receive an email.
Biomagician
CC BY-SA 4.0
2019-03-12T07:55:37.367Z
I'd be surprised if [--mail-user](https://github.com/dpryan79/Misc/blob/master/MPIIE_internal/SlurmEasy#L85-L90) didn't end up working. Note also `--mail-type`.
Devon Ryan
CC BY-SA 4.0
2019-03-16T15:48:15.603Z
so --mail-user on its own didn't work but by adding the --mail-type, it worked!
Biomagician
<snakemake><slurm>
How can I specify an email address in the SLURM snakemake json configuration file?
# How can I specify an email address in the SLURM snakemake json configuration file?

(Asked by: username_0 on 2019-03-11)

I am working on a SLURM-based cluster. I am currently using the following slurm json file:
{
    "__default__" :
    {
        "A" : "overall",
        "time" : "96:00:00",
        "nodes": 1,
        "ntasks": 1,
        "cpus" : 24,
        "p" : "LONG",
        "mem": 16G,
        "output": "snakemake%A.out",
        "error": "snakemake%A.err"
    }
}

along with the following command:
snakemake --jobs 200 --use-conda --printshellcmds  --cluster-config slurm.json --cluster "sbatch -A {cluster.A} -p {cluster.p} -t {cluster.time} --output {cluster.output} --error {cluster.error} --ntasks {cluster.ntasks} --cpus-per-task {cluster.cpus} --mem {cluster.mem}"

I would like to be able to specify my email and receive an email when a job finishes. I have tried adding a line in the json file with "email": my@email.com and an option to the sbatch command --email {cluster.email} but that did not work.
Anyone knows how to do it?

**Tags:** snakemake, slurm
> **Comments:**
> **username_0**: After looking at some headers of files (`#SBATCH --mail-user=email@com`I have used `--mail-user` instead. I'll let you know if I receive an email.  
> **username_1**: I'd be surprised if [--mail-user](https://github.com/dpryan79/Misc/blob/master/MPIIE_internal/SlurmEasy#L85-L90) didn't end up working. Note also `--mail-type`.  
> **username_0**: so --mail-user on its own didn't work but by adding the --mail-type, it worked!  

---

## 1 answers

### Answer by username_2 on 2019-03-15. Score: 4 | Accepted answer

As noted by the comments and the SLURM manual (not so much bioinformatics related?)
You need the following terms in your batch/queuing command:
--mail-type=ALL
--mail-user=you@email.com

I used "ALL" which will send you all reports. If you just want the finish message then you would use "END" and "FAIL" like such:
--mail-type=END,FAIL

Here are the specifics from the manual if you wish to make a different selection:
--mail-type=

Notify user by email when certain event types occur. Valid type values
  are NONE, BEGIN, END, FAIL, REQUEUE, ALL (equivalent to BEGIN, END,
  FAIL, REQUEUE, and STAGE_OUT), STAGE_OUT (burst buffer stage out and
  teardown completed), TIME_LIMIT, TIME_LIMIT_90 (reached 90 percent of
  time limit), TIME_LIMIT_80 (reached 80 percent of time limit),
  TIME_LIMIT_50 (reached 50 percent of time limit) and ARRAY_TASKS (send
  emails for each array task). Multiple type values may be specified in
  a comma separated list. The user to be notified is indicated with
  --mail-user. Unless the ARRAY_TASKS option is specified, mail notifications on job BEGIN, END and FAIL apply to a job array as a
  whole rather than generating individual email messages for each task
  in the job array.

--mail-user=

User to receive email notification of state changes as defined by
  --mail-type. The default value is the submitting user.


---

