Commit a28edb61 authored by sokai's avatar sokai

better cron modularisation (+CRONTAB)

parent 2b74e006
......@@ -22,6 +22,7 @@ SCRIPTVERSION='160201-1'
SCRIPT=${SCRIPTPATH}${SCRIPTNAME}
CRONTABPATH='/var/spool/cron/crontabs/' # _with_ trailing / !
CRONTABUSER='root'
CRONTAB="${CRONTABPATH}${CRONTABUSER}"
CRONINTERVAL=$(awk 'BEGIN{srand();print int(rand()*60)}') # run cron hourly at a random minute
WIF=$(ifconfig | awk '/10\.22\.[0-9]{1,3}\.[0-9]{1,3}/ {print $1}' RS="\n\n" | grep -m 1 wlan) # http://stackoverflow.com/a/18344694/338049
......@@ -49,7 +50,7 @@ SYSTEMTYPE=$(grep 'system type' /proc/cpuinfo|awk '{$1=$2=""; print}'| sed 's/
start() {
if ! $(grep -q ${SCRIPT} ${CRONTAB}); then
CRONJOB="${CRONINTERVAL} * * * * ${SCRIPT} update # FFP-AccessPointsDataBase"
echo "${CRONJOB}" >> ${CRONTABPATH}${CRONTABUSER}
echo "${CRONJOB}" >> ${CRONTAB}
echo "${CRONTABUSER}" > /var/spool/cron/crontabs/cron.update # reload crontab
logger -t ${SCRIPTNAME} "cron job for user ${CRONTABUSER} added (${SCRIPT} start)"
update
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment