diff options
author | Yorhel <git@yorhel.nl> | 2014-08-19 09:18:19 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2014-08-19 09:18:21 +0200 |
commit | 69f3fe73c5fbe1a4826802f14253bdeb58307a7c (patch) | |
tree | d084a93e505676e36605b7bdeeed9f7bebf73e96 /lib/Multi/Maintenance.pm | |
parent | 4be09bd3aee68c3f0b671eef21730f9a595c6e5c (diff) |
Multi: Run maintenance tasks at 12:00 GMT
In particular, don't run the tasks when I'm asleep. The SQL queries that
are run during maintenance can deadlock and cause multi to crash. I want
to be awake when that happens.
Diffstat (limited to 'lib/Multi/Maintenance.pm')
-rw-r--r-- | lib/Multi/Maintenance.pm | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/Multi/Maintenance.pm b/lib/Multi/Maintenance.pm index e7c66a04..f94e2734 100644 --- a/lib/Multi/Maintenance.pm +++ b/lib/Multi/Maintenance.pm @@ -52,11 +52,8 @@ sub shutdown { sub set_daily { - # run daily each day at 0:00 GMT - # (GMT because we're calculating on the UNIX timestamp, I can easily add an - # offset if necessary, but it doesn't really matter what time this cron - # runs, as long as it's run on a daily basis) - $_[KERNEL]->alarm(daily => int((time+3)/86400+1)*86400); + # run daily each day at 12:00 GMT + $_[KERNEL]->alarm(daily => int((time+3)/86400+1)*86400 + 12*3600); } @@ -72,11 +69,11 @@ sub daily { sub set_monthly { - # Calculate the UNIX timestamp of 0:00 GMT of the first day of the next month. + # Calculate the UNIX timestamp of 12:00 GMT of the first day of the next month. # We do this by simply incrementing the timestamp with one day and checking gmtime() # for a month change. This might not be very reliable, but should be enough for # our purposes. - my $nextday = int((time+3)/86400+1)*86400; + my $nextday = int((time+3)/86400+1)*86400 + 12*3600; my $thismonth = (gmtime)[5]*100+(gmtime)[4]; # year*100 + month, for easy comparing $nextday += 86400 while (gmtime $nextday)[5]*100+(gmtime $nextday)[4] <= $thismonth; $_[KERNEL]->alarm(monthly => $nextday); |