From the manual:
The qsub -m command requests email to be sent to the user who submitted a job or to the email addresses specified by the -M flag if certain events occur. See the qsub(1) man page for a description of the flags. An argument to the -m option specifies the events. The following arguments are available:
- b – Send email at the beginning of the job.
- e – Send email at the end of the job.
- a – Send email when the job is rescheduled or aborted (for example, by using the qdel command).
- s – Send email when the job is suspended.
- n – Do not send email. n is the default.
Use a string made up of one or more of the letter arguments to specify several of these options with a single -m option. For example, -m be sends email at the beginning and at the end of a job.
Thus, you can simply change your submit script like this:
#!/bin/bash
#$ -N NAME_OF_JOB
#$ -m a,s
#$ -M user1@ulb.ac.be,user2@gmail.com
#$ -cwd
This sends a mail to the two specified email addresses if the job is rescheduled or aborted. If you omit -M, the mail is send to the user who submitted the job.