mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Randomize sync time
This commit is contained in:
@@ -16,3 +16,5 @@ Display a more complete message if unable to get the hardware time from hwclock.
|
||||
---- Changes since 1.390 ----
|
||||
Changed the main page to use tabs to split up the system time, timezone and sync sections.
|
||||
Re-wrote all user interface code to use Webmin's new UI library.
|
||||
---- Changes since 1.420 ----
|
||||
The default NTP sync time is now set randomly instead of at midnight, and any existing automatic sync done at midnight is changed to a random time. This reduces load on public NTP servers.
|
||||
|
||||
@@ -166,8 +166,9 @@ if ( ( !$access{ 'sysdate' } && &has_command( "date" ) || !$access{ 'hwdate' } &
|
||||
print &ui_table_row($text{'index_sched'},
|
||||
&ui_radio("sched", $job ? 1 : 0,
|
||||
[ [ 0, $text{'no'} ], [ 1, $text{'index_schedyes'} ] ]));
|
||||
$job ||= { 'mins' => '0',
|
||||
'hours' => '0',
|
||||
&seed_random();
|
||||
$job ||= { 'mins' => int(rand()*60),
|
||||
'hours' => int(rand()*24),
|
||||
'days' => '*',
|
||||
'months' => '*',
|
||||
'weekdays' => '*' };
|
||||
|
||||
18
time/postinstall.pl
Normal file
18
time/postinstall.pl
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
require 'time-lib.pl';
|
||||
|
||||
# Change time sync jobs running at midnight to a random time, to stop
|
||||
# overloading public NTP servers
|
||||
sub module_install
|
||||
{
|
||||
&foreign_require("cron", "cron-lib.pl");
|
||||
local $job = &find_cron_job();
|
||||
if ($job && $job->{'mins'} eq '0' && $job->{'hours'} eq '0') {
|
||||
# Midnight .. fix it
|
||||
&seed_random();
|
||||
$job->{'mins'} = int(rand()*60);
|
||||
$job->{'hours'} = int(rand()*24);
|
||||
&cron::change_cron_job($job);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user