From 3563f28e8d48e47f48b2ab07666c90e70d2f8c87 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 10 Mar 2015 19:24:57 +0000 Subject: [PATCH] Randomize monthly cron job time --- src/freedombone | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/freedombone b/src/freedombone index 0ae53733..1cc49e05 100755 --- a/src/freedombone +++ b/src/freedombone @@ -1060,14 +1060,14 @@ function install_not_on_BBB { function randomize_cron { # The predictable default timing of Debian cron jobs might # be exploitable knowledge. Avoid too much predictability - # by randomizing the times when cron jobs run + # by randomizing the times when cron jobs run if grep -Fxq "randomize_cron" $COMPLETION_FILE; then return fi # randomize the day on which the weekly cron job runs randdow=$(($RANDOM%6+1)) - sed -i "s/* * 7/* $randdow/g" /etc/crontab + sed -i "s|\* \* 7|* * $randdow|g" /etc/crontab # randomize the time when the weekly cron job runs randmin=$(($RANDOM%60)) @@ -1077,12 +1077,15 @@ function randomize_cron { # randomize the time when the daily cron job runs randmin=$(($RANDOM%60)) randhr=$(($RANDOM%3+4)) - sed -i "s|25 6\t* * *|$randmin $randhr\t|g" /etc/crontab + sed -i "s|25 6\t\* \* \*|$randmin $randhr\t* * *|g" /etc/crontab # randomize the time when the hourly cron job runs randmin=$(($RANDOM%60)) - sed -i "s|17 *\t* * *|$randmin *\t|g" /etc/crontab + sed -i "s|17 \*\t|$randmin *\t|g" /etc/crontab + # randomize monthly cron job time and day + sed -i "s|52 6\t|$randmin $randhr\t|g" /etc/crontab + sed -i "s|\t1 \* \*|\t$randdom * *|g" /etc/crontab echo 'randomize_cron' >> $COMPLETION_FILE }