如何设置LSF数组任务仅在任务失败时发送邮件?
Configure LSF Array Jobs to Send Emails Only on Failure
Absolutely! You can adjust your LSF job submission parameters to only receive email notifications when an array task fails, instead of getting a notification for every completed task. Here's how to modify your configuration:
Modified BSUB Script
#BSUB -J "myArray[1-50]" #BSUB -o o.%J.%I #BSUB -e e.%J.%I #BSUB -W 10:00 #BSUB -notify "EXIT:!=0" # Only trigger email on non-zero exit codes (failure) #BSUB -u myEmail@somewhere.com
Key Changes Explained
- Replace the original
#BSUB -Nwith#BSUB -notify "EXIT:!=0":- The
-notifyparameter lets you specify exactly when LSF sends notifications. EXIT:!=0tells LSF to only send an email if a task exits with a non-zero exit code (which indicates a failure). Successful tasks (exit code 0) won't trigger any email.
- The
- You keep all other parameters (
-J,-o,-e,-W,-u) as they are—these handle the array job definition, output/error logging, runtime limit, and recipient email respectively.
Expected Outcome
With this setup:
- You'll only receive emails for array tasks that fail (e.g., tasks 11, 12, 25 in your example).
- Each failure email will have a title like:
Job 123456[11]: <myArray[1-50]> in cluster
Exited - Successful tasks won't send any notifications, so you won't get 50 emails when all jobs finish successfully.
Notes for Compatibility
If your LSF version doesn't support the EXIT:!=0 conditional syntax (older versions might have limited -notify functionality), you can use a simpler approach:
- Keep
#BSUB -Nbut add a check in your job script to only generate error output on failure. However, this relies on your script correctly capturing failures. - Alternatively, check your cluster's LSF documentation for version-specific notification options.
内容的提问来源于stack exchange,提问作者zx8754
相关产品推荐
相关产品推荐

