Package: cronic Version: 3-1 Severity: wishlist Tags: patch upstream Dear Maintainer,
An increasing number of applications we use through cron are putting debug output on STDERR while returning 0 by default, and cannot be quietened. Examples include docker and gitlab maintenance We have locally patched our cronic to support an option, -r, which will cause cronic to only generate a report if the return code is nonzero, even if there is STDERR output. We submit it for your consideration. -- System Information: Debian Release: 9.9 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.9.0-9-amd64 (SMP w/4 CPU cores) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages cronic depends on: ii bash 4.4-5 cronic recommends no packages. Versions of packages cronic suggests: ii cron 3.0pl1-128+deb9u1 -- no debconf information
--- cronic.orig 2019-05-13 17:46:13.150590183 +0100 +++ cronic 2019-05-13 17:19:01.098080693 +0100 @@ -11,6 +11,18 @@ ERR=$TMP/cronic.err TRACE=$TMP/cronic.trace +CRONIC_RESULT_ONLY="" + +# Go over $@ to look for - parameters +while getopts r opt; do + case $opt in + r) + CRONIC_RESULT_ONLY="yes" + ;; + esac +done +shift "$((OPTIND-1))" + set +e "$@" >$OUT 2>$TRACE RESULT=$? @@ -24,7 +36,7 @@ ERR=$TRACE fi -if [ $RESULT -ne 0 -o -s "$ERR" ] +if [[ -n "$CRONIC_RESULT_ONLY" && $RESULT -ne 0 ]] || [[ -z "$CRONIC_RESULT_ONLY" && ( $RESULT -ne 0 || -s "$ERR" ) ]] then echo "Cronic detected failure or error output for the command:" echo "$@"