cronie/contrib/0anacron

28 lines
580 B
Plaintext
Raw Permalink Normal View History

2019-08-06 18:08:05 +02:00
#!/bin/sh
# Check whether 0anacron was run today already
2017-05-08 15:30:03 +02:00
if test -r /var/spool/anacron/cron.daily; then
day=`cat /var/spool/anacron/cron.daily`
fi
if [ `date +%Y%m%d` = "$day" ]; then
2019-08-06 18:08:05 +02:00
exit 0
2017-05-08 15:30:03 +02:00
fi
2019-08-06 18:08:05 +02:00
# Do not run jobs when on battery power
online=1
2021-08-09 15:08:54 +02:00
for psupply in AC ADP{0..9} ; do
2019-08-06 18:08:05 +02:00
sysfile="/sys/class/power_supply/$psupply/online"
if [ -f $sysfile ] ; then
if [ `cat $sysfile 2>/dev/null`x = 1x ]; then
online=1
break
else
online=0
fi
2017-05-08 15:30:03 +02:00
fi
2019-08-06 18:08:05 +02:00
done
if [ $online = 0 ]; then
exit 0
2017-05-08 15:30:03 +02:00
fi
/usr/sbin/anacron -s