Randomize monthly cron job time
This commit is contained in:
parent
1c52727b71
commit
3563f28e8d
|
@ -1067,7 +1067,7 @@ function randomize_cron {
|
||||||
|
|
||||||
# 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