Top
Best
New

Posted by pera 1 day ago

Avoid 2:00 and 3:00 am cron jobs (2013)(www.endpointdev.com)
327 points | 366 commentspage 3
jcynix 1 day ago|
> better open source job scheduler [...] one that will ensure no overlapping runs

Or learn to use lock files, which would make sure that your jobs don't run when another one is already running?

Unix shells offer the trap command, among other things, to cleanup, even in the case of errors, e.g.:

   set -e
   LOCK=$(ensure-lock)
   trap "rm $LOCK" 0 1 2 15
   do-job
https://en.wikipedia.org/wiki/Semaphore_%28programming%29
TylerE 1 day ago|
Tell me how that goes after a server malfunction or power failure. Where is your trap god then?
jcynix 1 day ago||
The topic was to prevent overlapping runs. In case of power failures etc all your server processes have this problem. That's why, for example, /var/run exists and files/directories are deleted from /var/run on reboot?
magarnicle 1 day ago||
The problem is not so much which timezone you pick, the problem is that cron uses 'naive' datetimes. If the timezone is explicit then you don't have duplicate hours because one is 02:00 and one is 02:00DST.

And then you can translate that time to any other timezone with ease, knowing that you are referencing a specific hour in physical time that only ever happened once.

LeoPanthera 1 day ago||
> knowing that you are referencing a specific hour in physical time that only ever happened once

"Falsehoods programmers believe about time"

This assumption can break with:

* Leap seconds

* Calendar and time zone changes

* (In exotic circumstances) Relativity

magarnicle 1 day ago||
I'll give you leap seconds, but at least in Python historical timezone changes are recorded in the datetime library, so the timezone at any particular time in the past has the timezone offset that was active then.
magarnicle 1 day ago||
Which is to say I wish cron had the TZ variable that Jenkins uses in it's scheduling system. And the H value to easily spread multiple jobs over the hour/day/month etc.
MayeulC 1 day ago||
Not a crown job, but I configured my lights to turn on progressively at my scheduled wake up time, using Home Assistant.

I figured that scheduling lights to turn on at <0 AM + wake up time> was a good approach... We got a surprise early wake up last year, so I ended up changing the formula to <4 AM - 4 hours + wake-up time>.

nubinetwork 1 day ago||
Doesn't systemd timers fix this? AFAIK, a job set to run once a day shouldn't run a second time because the time rolled back.
tomkaos 1 day ago||
I avoid cron job at this time for this reason and for many other random problem because 3:00 am seem to be often choose for a maintenance like automatic update, server reboot, database backup..
tclancy 1 day ago|
Can be tricky: an old project had a job that ran every 15 minutes to poll data from a popular smart thermostat company. I always knew when DST was starting or ending because that job would throw an error email at 2/3am on those days.
skopje 1 day ago||
UTC also solves plotting daily time plots in zones with time changes (twice a year when the plots make no sense). But there still isn't no good fix for leap year plots!
bobmcnamara 1 day ago|
Just use TAI?
cadamsdotcom 1 day ago||
Great to read about something that's a solved problem now. It's been a very long time since I used a server that wasn't set to UTC.
bobmcnamara 1 day ago|
I've seen this same problem under UTC. Gotta use TAI
cmiles8 1 day ago||
Or just use UTC and stop using timezones in code. I get it’s not that simple for some use cases but UTC exists for a reason.
bobmcnamara 1 day ago|
Use TAI.

UTC has most of the same wacky timezone problems, just less often.

ericpauley 1 day ago||
You’re signing up for a world of pain in the real world, where every other system is UTC. Just use UT1 or smear the leap second if you really can’t stand the risk.
bobmcnamara 22 hours ago||
Approaching one second per second, is that so much to ask?

Unless standardization has improved, how+when the second is smeared(if at all) means timestamps from the same system aren't usefully subtractable without communicating a separate time skew calendar.

That said, time is a big topic, and everything has different requirements but migrating to TAI and treating UTC as yet another human readable time zone has solved more (admittedly application specific) problems than it created.

dathinab 1 day ago|
2-3am is bad due to DST but there is another reason to also avoid 3-5am or so

around 3am is the time where "in average" human attention is the worst as its where "in average" their most relevant deep sleep phases are

now I guess the average over HN readers has a good chance to be somewhat later

but either way if the job goes wrong and triggers alarms 2-5am it very bad for the the health and sleep rithm of whoever needs to fix it and the most likely time they make mistakes

it sadly is also the time where non-international interruptions are least likely to matter

if you are an international company having international teams can be an solution

and if you are a very small team adopting job times to an overlap of low usage and your admins sleep habits can be an option

but if you need to pick a generic time and don't provide for logistics or other "start work at 4/5am" companies probably 5-6am is a better time to run your batch jobs

anyway just some random thoughts

More comments...