Script to send email not working when run on SLURM

125 Views Asked by At

I have a bash script that performs various weekly data collection tasks and generates a report which is then echoed into an email to be sent. I have ran the script manually in the Linux terminal and have confirmed I can receive emails from it. The script is in the following format:

#!/bin/bash

### Code to perform data collection and generate an output text file ###

(
echo "Email greeting..."
echo "${OUTPUT}"
echo "More email stuff..."
) | mail -s "subject" "email@address"

echo "Report from ${OUTPUT} sent."

Some of the data collection tasks are quite resource intensive so I have written a batch job submission script to submit the job into a queue for HPC compute power as follows:

#!/bin/bash

#SBATCH --job-name=DATA_COLLECTION_REPORT
#SBATCH --ntasks=1
#SBATCH --time=06:00:00
#SBATCH --mem-per-cpu=250G
#SBATCH --partition=cpu

bash /PATH/TO/DATA_COLLECTION_SCRIPT.sh

Then to automate the submission, I simply used crontab to schedule the job. To illustrate, when I run crontab -l, the terminal returns the following:

0 1 * * 1 sbatch /PATH/TO/SLURM_DATA_COLLECTION_JOB_SCRIPT.sh

I can confirm the crontab job executes as I get e-mails from the cron daemon. Moreover, SLURM runs and completes my job as I have a SLURM output file which reads:

Report from output/file/path/OUTPUT_FILE.txt sent.

However I never receive the emails.

I have also attempted to run the script with crontab with a dummy report to skip the resource intensive data collection stage. I manually create the OUTPUT_FILE.txt and install a cronjob to just send the email. This works fine, so I would presume there an issue with SLURM running the email portion of the script.

1

There are 1 best solutions below

5
nisakova On

you can test the slurm part by adding the specific node name --nodelist=one_of_your_node_name_in_the_cpu_partition and removing the --time or reducing it to XX minutes