Last active
December 26, 2020 18:19
-
-
Save hn-support/c8842fd4a904484e800d8f4f486365da to your computer and use it in GitHub Desktop.
Revisions
-
hn-support revised this gist
May 3, 2017 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,11 @@ #!/bin/bash # This script is a debug utility for cronjobs as explained in: # - https://support.hypernode.com/knowledgebase/configure-cronjobs-on-hypernode/ # It logs all output and timing to a log file # # To use it, download the script, add the executable bit and put it in your cronjob: # */5 * * * * /data/web/bin/debug-cron php -f /data/web/public/cron.php LOGDIR="/data/web/public/var/log/crons" TIMESTAMP="$( date '+%Y%m%d%H%M' )" FILENAME="$LOGDIR/cronjob-${TIMESTAMP}.log" -
hn-support revised this gist
Sep 22, 2016 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,6 @@ LOGDIR="/data/web/public/var/log/crons" TIMESTAMP="$( date '+%Y%m%d%H%M' )" FILENAME="$LOGDIR/cronjob-${TIMESTAMP}.log" function log() { while read LOG ; do echo "$(date) - $LOG" | tee -a $FILENAME @@ -27,4 +26,4 @@ fi echo "Running cron job \'${COMMAND}\'" | log ${COMMAND} | log EXITCODE="$?" echo "Cron job \'${COMMAND}\' finished with exit code ${EXITCODE}" | log -
hn-support created this gist
Sep 22, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/bash LOGDIR="/data/web/public/var/log/crons" TIMESTAMP="$( date '+%Y%m%d%H%M' )" FILENAME="$LOGDIR/cronjob-${TIMESTAMP}.log" function log() { while read LOG ; do echo "$(date) - $LOG" | tee -a $FILENAME done < "${1:-/dev/stdin}" } ## Test if log dir is present [ -d "${LOGDIR}" ] || mkdir -p "${LOGDIR}" ## Get arguments from script SCRIPTNAME="$0" COMMAND="${@}" ## Exit if no arguments if [ "${COMMAND}x" == "x" ] ; then echo "$0 Usage $SCRIPTNAME <command>" exit 1 fi ## Log and run echo "Running cron job \'${COMMAND}\'" | log ${COMMAND} | log EXITCODE="$?" echo "Cron job \'${COMMAND}\' finished with exit code ${EXITCODE}" | log