Skip to content

Commit a509676

Browse files
committed
Add option to dump latest log file in case of error
1 parent ff46de9 commit a509676

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Utilities/Tools/jobutils.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ taskwrapper_cleanup_handler() {
8989
# Main features provided at the moment are:
9090
# - optional recording of walltime and memory consumption (time evolution)
9191
# - optional recording of CPU utilization
92-
# - Some job control and error detection (in particular for DPL workflows).
92+
# - Some job control and error detection (in particular for DPL workflows).
9393
# If exceptions are found, all participating processes will be sent a termination signal.
94-
# The rational behind this function is to be able to determine failing
95-
# conditions early and prevent longtime hanging executables
94+
# The rational behind this function is to be able to determine failing
95+
# conditions early and prevent longtime hanging executables
9696
# (until DPL offers signal handling and automatic shutdown)
9797
# - possibility to provide user hooks for "start" and "failure"
9898
# - possibility to skip (jump over) job alltogether
@@ -114,7 +114,7 @@ taskwrapper() {
114114
chmod +x ${SCRIPTNAME}
115115

116116
# this gives some possibility to customize the wrapper
117-
# and do some special task at the start. The hook takes 2 arguments:
117+
# and do some special task at the start. The hook takes 2 arguments:
118118
# The original command and the logfile
119119
if [ "${JOBUTILS_JOB_STARTHOOK}" ]; then
120120
hook="${JOBUTILS_JOB_STARTHOOK} '$command' $logfile"
@@ -167,7 +167,7 @@ taskwrapper() {
167167
# We don't like to see critical problems in the log file.
168168

169169
# We need to grep on multitude of things:
170-
# - all sorts of exceptions (may need to fine-tune)
170+
# - all sorts of exceptions (may need to fine-tune)
171171
# - segmentation violation
172172
# - there was a crash
173173
# - bus error (often occuring with shared mem)
@@ -193,7 +193,7 @@ taskwrapper() {
193193
echo "Detected critical problem in logfile $logfile"
194194

195195
# this gives some possibility to customize the wrapper
196-
# and do some special task at the start. The hook takes 2 arguments:
196+
# and do some special task at the start. The hook takes 2 arguments:
197197
# The original command and the logfile
198198
if [ "${JOBUTILS_JOB_FAILUREHOOK}" ]; then
199199
hook="${JOBUTILS_JOB_FAILUREHOOK} '$command' $logfile"
@@ -206,6 +206,7 @@ taskwrapper() {
206206

207207
RC_ACUM=$((RC_ACUM+1))
208208
[ ! "${JOBUTILS_KEEPJOBSCRIPT}" ] && rm ${SCRIPTNAME} 2> /dev/null
209+
[ "${JOBUTILS_PRINT_ON_ERROR}" ] && cat ${logfile}
209210
[[ ! "${JOBUTILS_NOEXIT_ON_ERROR}" ]] && [[ ! $- == *i* ]] && exit 1
210211
return 1
211212
fi
@@ -305,6 +306,7 @@ taskwrapper() {
305306
hook="${JOBUTILS_JOB_FAILUREHOOK} '$command' $logfile"
306307
eval "${hook}"
307308
fi
309+
[ "${JOBUTILS_PRINT_ON_ERROR}" ] && echo ----- Last log: ----- && pwd && cat ${logfile} && echo ----- End of log -----
308310
return 1
309311
fi
310312
fi
@@ -321,6 +323,7 @@ taskwrapper() {
321323
hook="${JOBUTILS_JOB_FAILUREHOOK} '$command' $logfile"
322324
eval "${hook}"
323325
fi
326+
[ "${JOBUTILS_PRINT_ON_ERROR}" ] && echo ----- Last log: ----- && pwd && cat ${logfile} && echo ----- End of log -----
324327
return 1
325328
fi
326329
fi
@@ -356,6 +359,7 @@ taskwrapper() {
356359
fi
357360
else
358361
echo "command ${command} had nonzero exit code ${RC}"
362+
[ "${JOBUTILS_PRINT_ON_ERROR}" ] && echo ----- Last log: ----- && pwd && cat ${logfile} && echo ----- End of log -----
359363
fi
360364
[ ! "${JOBUTILS_KEEPJOBSCRIPT}" ] && rm ${SCRIPTNAME} 2> /dev/null
361365

@@ -366,7 +370,7 @@ taskwrapper() {
366370
o2_cleanup_shm_files #--> better to register a general trap at EXIT
367371

368372
# this gives some possibility to customize the wrapper
369-
# and do some special task at the ordinary exit. The hook takes 3 arguments:
373+
# and do some special task at the ordinary exit. The hook takes 3 arguments:
370374
# - The original command
371375
# - the logfile
372376
# - the return code from the execution

0 commit comments

Comments
 (0)