diff options
Diffstat (limited to 'src/infrastructure/scripts/cronjob.sh')
-rwxr-xr-x | src/infrastructure/scripts/cronjob.sh | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/infrastructure/scripts/cronjob.sh b/src/infrastructure/scripts/cronjob.sh index 4823ac1..67ba885 100755 --- a/src/infrastructure/scripts/cronjob.sh +++ b/src/infrastructure/scripts/cronjob.sh @@ -86,6 +86,10 @@ set -eu +epoch() { + awk 'BEGIN { srand(); print(srand()); }' +} + now() { date '+%Y-%m-%dT%H:%M:%S%:z' } @@ -104,7 +108,12 @@ mkstemp() { } pre() { - sed -u "s|^|[$CMD]: |" + # Same as: + # sed -u "s|^|[$CMD]: |" + # but the "-u" option is not POSIX + while read -r line; do + printf '[%s]: %s\n' "$CMD" "$line" + done } duration() { @@ -139,16 +148,16 @@ trap email EXIT { cat <<-EOF - Running commad: $* + Running commad: $CMD Starting at: $(now) EOF - START="$(date +%s)" + START="$(epoch)" STATUS=0 timeout "$ONE_HOUR" "$@" || STATUS=$? printf '%s' "$STATUS" > "$STATUS_F" - END="$(date +%s)" + END="$(epoch)" DURATION_SECONDS=$((END - START)) cat <<-EOF |