Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
en:services:application_services:high_performance_computing:running_jobs_slurm:signals [2021/05/25 14:27]
mboden [Trapping the Signal]
en:services:application_services:high_performance_computing:running_jobs_slurm:signals [2021/05/25 14:38] (current)
mboden [Trapping the Signal]
Line 13: Line 13:
  
 But just sending a signal is not enough, the job needs to know what to do with the signal. The easiest way to do that is to use a [[https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#index-trap|trap]]. This command can be used to define steps that should be taken, when the signal is received, for example: But just sending a signal is not enough, the job needs to know what to do with the signal. The easiest way to do that is to use a [[https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#index-trap|trap]]. This command can be used to define steps that should be taken, when the signal is received, for example:
-<code bash> trap 'mkdir -p ${HOME}/job_${SLURM_JOBID}; cp -af ${TMP_LOCAL}/* ${HOME}/job_${SLURM_JOBID}/; exit 12' 12</code>+<code bash>trap 'mkdir -p ${HOME}/job_${SLURM_JOBID}; cp -af ${TMP_LOCAL}/* ${HOME}/job_${SLURM_JOBID}/; exit 12' 12</code>
 This will trap the signal 12 and run the command given commands to create a folder in the home directory with the JobID of the job and copy all files from the local disk (located at ''$TMP_LOCAL'') into this directory. Some more examples of using signals and traps can be found [[https://www.tutorialspoint.com/unix/unix-signals-traps.htm|here]]. This will trap the signal 12 and run the command given commands to create a folder in the home directory with the JobID of the job and copy all files from the local disk (located at ''$TMP_LOCAL'') into this directory. Some more examples of using signals and traps can be found [[https://www.tutorialspoint.com/unix/unix-signals-traps.htm|here]].