appending to logfile

This commit is contained in:
Udo Waechter
2013-06-05 15:56:03 +02:00
parent 44c8ba91bc
commit 96f25ace50
2 changed files with 1 additions and 43 deletions

View File

@@ -1,42 +0,0 @@
#!/usr/bin/env bash
# a wrapper script, to run puppetd after a random time
# this will be called by cron at the same time on each client,
# but should not call the master at the same time as the others.
[ -e /etc/profile ] && . /etc/profile
PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PUPPET=$(which puppetd)
ISUNIIP=$(ifconfig |grep -c -e "131\.173\.3[2345]")
if [ ${ISUNIIP} -gt 0 ]; then
if [ -e ${PUPPET} ]; then
#mac os X laptop check
if [ -e /usr/bin/pmset ]; then
if [ $(/usr/bin/pmset -g batt | grep -c "Battery Power") -eq 1 ]; then
#we are running on battery and do not want to do anything
exit 0
fi
fi
#Linux laptop check
if [ -e /proc/acpi/ac_adapter/AC/state ]; then
if [ $(grep -c "on-line" /proc/acpi/ac_adapter/AC/state) -eq 0 ]; then
#we are running on battery and do not want to do anything
exit 0
fi
fi
MAXSLEEP=3200 #How many seconds to wait maximally
SLEEP=${RANDOM}
I=${RANDOM}
# $RANDOM must be called several times, to ensure it really
# is something like random
for x in 1 2 3 4 5 6 7 8 9 10 11 12; do
SLEEP=${RANDOM}
done
# wait maximally $MAXSLEEP seconds
sleep $(expr ${SLEEP} % ${MAXSLEEP})
# run puppetd
nice -n 12 $PUPPET -t 2&>/var/log/puppet/puppetd_run.log
fi
fi

View File

@@ -66,7 +66,7 @@ if [ ${ISUNIIP} -gt 0 ]; then
# wait maximally $MAXSLEEP seconds
sleep $(expr ${SLEEP} % ${MAXSLEEP})
# run puppetd
nice -n 12 $PUPPET agent -t 2&>/var/log/puppet/puppetd_run.log
nice -n 12 $PUPPET agent -t 2&>>/var/log/puppet/puppetd_run.log
fi
fi
# cleanup the pidfile