---- 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.
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' => '*' };
--- /dev/null
+
+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);
+ }
+}
+