This simple script (simple_mail.sbatch
) will send two mails if run directly from the command line. It runs fine on the head node and any of the cluster nodes I've tried:
#!/bin/bash
echo "Getting ready to send an e-mail from $HOSTNAME"
# Try using a pipe
echo 'Testing pipe version' | mailx -s 'testing mail app' user@example.com
# Try using a heredoc
mailx -s 'testing mail app' user@example.com << 'END'
Testing < version
END
echo "Finished on $HOSTNAME"
However, when run using sbatch
, I see the results of the first and last echo commands in the captured standard output, but no e-mail is sent.
sbatch simple_mail.sbatch
A "wrapped" command and srun
don't fair any better:
sbatch --wrap='echo "Testing" | mailx -s "testing mail app" user@example.com'
srun ./simple_mail.sbatch
Version info:
slurm 14.11.8
CentOS Linux release 7.1.1503 (Core)
Heirloom mailx 12.5
By the way, mailx
may be called as mail
on some systems.
I've looked at other slurm and mailx questions on stackoverflow, but none seemed to address this problem.
I've looked at environment variables and have even tried setting all of the environment variables to be the same (even those starting with SLURM) but the difference in behavior still remains.