Randomize monthly cron job time
This commit is contained in:
parent
1c52727b71
commit
3563f28e8d
|
@ -1060,14 +1060,14 @@ function install_not_on_BBB {
|
||||||
function randomize_cron {
|
function randomize_cron {
|
||||||
# The predictable default timing of Debian cron jobs might
|
# The predictable default timing of Debian cron jobs might
|
||||||
# be exploitable knowledge. Avoid too much predictability
|
# 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
|
if grep -Fxq "randomize_cron" $COMPLETION_FILE; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# randomize the day on which the weekly cron job runs
|
# randomize the day on which the weekly cron job runs
|
||||||
randdow=$(($RANDOM%6+1))
|
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
|
# randomize the time when the weekly cron job runs
|
||||||
randmin=$(($RANDOM%60))
|
randmin=$(($RANDOM%60))
|
||||||
|
@ -1077,12 +1077,15 @@ function randomize_cron {
|
||||||
# randomize the time when the daily cron job runs
|
# randomize the time when the daily cron job runs
|
||||||
randmin=$(($RANDOM%60))
|
randmin=$(($RANDOM%60))
|
||||||
randhr=$(($RANDOM%3+4))
|
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
|
# randomize the time when the hourly cron job runs
|
||||||
randmin=$(($RANDOM%60))
|
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
|
echo 'randomize_cron' >> $COMPLETION_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue