Skip to content
This repository was archived by the owner on Feb 24, 2022. It is now read-only.

Commit 830338a

Browse files
committed
Improve cron script to hide command output unless it fails
Fixes rodjek#24 Fixes rodjek#16
1 parent b3cee76 commit 830338a

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

files/etc/cron.daily/logrotate

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@
22
# THIS FILE IS AUTOMATICALLY DISTRIBUTED BY PUPPET. ANY CHANGES WILL BE
33
# OVERWRITTEN.
44

5-
test -x /usr/sbin/logrotate || exit 0
6-
/usr/sbin/logrotate /etc/logrotate.conf
5+
OUTPUT=$(/usr/sbin/logrotate /etc/logrotate.conf 2>&1)
6+
EXITVALUE=$?
7+
if [ $EXITVALUE != 0 ]; then
8+
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
9+
echo "${OUTPUT}"
10+
fi
11+
exit $EXITVALUE

files/etc/cron.hourly/logrotate

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@
22
# THIS FILE IS AUTOMATICALLY DISTRIBUTED BY PUPPET. ANY CHANGES WILL BE
33
# OVERWRITTEN.
44

5-
test -x /usr/sbin/logrotate || exit 0
6-
/usr/sbin/logrotate /etc/logrotate.d/hourly
5+
OUTPUT=$(/usr/sbin/logrotate /etc/logrotate.d/hourly 2>&1)
6+
EXITVALUE=$?
7+
if [ $EXITVALUE != 0 ]; then
8+
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
9+
echo "${OUTPUT}"
10+
fi
11+
exit $EXITVALUE

0 commit comments

Comments
 (0)