ceph/qa/nightlies/cron_wrapper
Patrick Donnelly 6d6837834b
qa/nightlies: simplify cron_wrapper and log to syslog
Instead of logging to a separate file which must be rotated manually, use the
syslog (journald on teuthology.front).

Keep a temporary unlinked file around in case we want to dump that to the
cronjob stdout for a mail status.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
2024-03-11 13:45:52 -04:00

24 lines
439 B
Bash
Executable File

#!/usr/bin/env bash
# check for no argument case and stop
if [ -z $1 ]; then
echo "need argument"
exit 1
fi
# Make a temporary unlinked file to hold the stdout/stderr
T=$(mktemp)
exec 10>"$T"
exec 11<"$T"
rm -f "$T"
# Forward to syslog (journald)
printf 'Running command: %s' "$*" | logger
"$@" |& tee >(logger) >&10
code=$?
if [ "$code" != 0 ] ; then
printf 'teuthology cronjob encountered error:\n'
head -n 10000 <&11
fi