Search code examples
emailjob-schedulingmailxslurm

Should I expect that mailx would work with SLURM?


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' [email protected]

# Try using a heredoc
mailx -s 'testing mail app' [email protected] << '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" [email protected]'

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.


Solution

  • This isn't a direct answer, but it works: Try mutt instead.

    After spending too much time trying to get mailx to work, we tried mutt and it does the job. After mutt was installed and confirmed to work, I tried mailx again (as a sanity check), but it still does not work when run by the SLURM scheduler.