Skip to content

Instantly share code, notes, and snippets.

@fawkesley
Created December 18, 2017 21:16
Show Gist options
  • Save fawkesley/b0d27fe85cf8e83b175c4adac7178909 to your computer and use it in GitHub Desktop.
Save fawkesley/b0d27fe85cf8e83b175c4adac7178909 to your computer and use it in GitHub Desktop.
cron-wrap
#!/bin/sh -u
LOG_FILE="${HOME}/log/$(date --iso-8601=seconds).log"
touch "${LOG_FILE}"
$1 "$@" >> ${LOG_FILE} 2>&1
EXIT_CODE=$?
if [ "${EXIT_CODE}" -ne "0" ]; then
tail -n 100 "${LOG_FILE}"
exit ${EXIT_CODE}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment