-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from bast/radovan/trap
show how to clean up a timed-out job
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash -l | ||
|
||
# job name | ||
#SBATCH --job-name=example | ||
|
||
# replace this by your account | ||
#SBATCH --account=... | ||
|
||
# one core only | ||
#SBATCH --tasks=1 | ||
|
||
# we give this job 4 minutes | ||
#SBATCH --time=0-00:04:00 | ||
|
||
# asks SLURM to send the USR1 signal 120 seconds before end of the time limit | ||
#SBATCH --signal=B:USR1@120 | ||
|
||
# define the handler function | ||
# note that this is not executed here, but rather | ||
# when the associated signal is sent | ||
your_cleanup_function() | ||
{ | ||
echo "function your_cleanup_function called at $(date)" | ||
# do whatever cleanup you want here | ||
} | ||
|
||
# call your_cleanup_function once we receive USR1 signal | ||
trap 'your_cleanup_function' USR1 | ||
|
||
echo "starting calculation at $(date)" | ||
|
||
# the calculation "computes" (in this case sleeps) for 1000 seconds | ||
# but we asked slurm only for 240 seconds so it will not finish | ||
# the "&" after the compute step and "wait" are important | ||
sleep 1000 & | ||
wait |