Forwarding Job Complete Scripts and emails from MONSooN

(Met Office and NERC Supercomputing Node)

When running a Job it is often highly useful to get a notification on completion (or failure) currently this happens automatically, without the user knowing — with the exception of the occasional terminal message.

Where is mail stored?

By default, all correspondence is stored at

/var/mail/<short 6 character username> 

If you are unsure what your username is, type $USER or echo '/var/mail/$USER' to get the path. This gives a list of messages outlining your different runs, and their final status.

Alternatively typing in "mail” opens the terminal client and lets you browse messages more readily if you wish to use this method.

Setting up a forwarding address

This is done by creating a .forward file in your $HOME directory. This can be done using a cat command:

cat > $HOME/.forward

next, you enter your preferred email and hit carriage return — e.g.

name@email.ac.uk <press enter key>

And exit using < ctrl+d > .

Finally, we change the permissions of this file with chmod 600 $HOME/.forward

Sending a test email

Finally to make sure it is all working as intended we send ourselves a test email using:

mail $USER

where $USER just substitutes your username. You can type this manually if you wish.

This will prompt you for an email subject

Subject: Lets test this mail

After pressing the enter key we can then go ahead and enter our message content.

This is a not-so creative email body. Yours Sincerely, 
Myself

When you are done press the enter key again and < ctrl + d > to end the message.

Finally

Open the email in your .forward file, and you should have the message you just typed sitting in your mailbox!

I presume you might be able to email other users in the same format, although this has not been tried — have fun!

Extra — debugging

If you wish to add a debug email as test — e.g. within the cleanup text for a Unified Model run you can use the following one-liner:

mailx -s "my-subject" $USER <<<$'\n Body Text \n'

It would also be able to pipe the contents of a text file into the message if needed.

Research Software Engineer specialising in Data Visualisation with a touch of HPC. — PhD in Atmospheric Chemistry and Masters in Theoretical Physics.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store