Managing Batch Jobs for Several Time Zones? 44
sporty asks: "I have one machine, a unix box, that serves many time zones at once. Because of this, everything is stored in GMT. Even the system clock is set relative to GMT. The problem is determining when midnite is. I need to run certain jobs, via cron or similar, so that something runs at midnite in that timezone. Anyone have this situation before?"
Re:Why midnight? (Score:2)
GMT doesn't change so all you need to do is keep a list of each machine and it's GMT offset and schedule your scripts accordingly.
Re:Why midnight? (Score:1)
GMT doesn't change, but the offset changes at least twice a year. Currently here (Sweden) it's GMT+2 since we are in daylight saving period, but usually we are in the GMT+1 timezone. So then you have to twice a year adjust when the script is run, and apparently not everyone change to/from daylight saving time at the same time, which means even more headache
Re:Why midnight? (Score:2)
I thought you could use NTP on each machine to keep the time correct even during offset months?
Re:Why midnight? (Score:2)
I've seen some strange moderation in my time, however could anyone explain to me how the above post could possibly be considered "offtopic"?
Re:Why midnight? (Score:2)
Not enough information (Score:5, Interesting)
Why not set up a set of groups with defined IDs (say maybe 1000 - 1047) for each timezone. Allocate users in the appropriate timezone to those groups
Run a master script every hour (or half hour) which su's to a dummy member of that group and runs some script. you get some protection from accidentally breaking things by running as root.
Care to tell us exactly what the obvious solutions don't do? what you're trying to do maybe?
Re:Not enough information (Score:3, Informative)
Writing a job managing job on top of a job managing job (at on cron) could get messy. Especially so when day light savings hits for various places.
Re:Not enough information (Score:2)
What sort of thing is it that needs to be done every half hour of every day on the one unix box?
I assume that you have a bunch of users, each of whom is assumed to be in a given timezone. You need to do something for each user at midnight in their timezone and you're worrie
GMT offsets are your friend. (Score:2, Informative)
-Use that to figure out what GMT time is midnight for each time zone.
-Make a cron job for each time zone to run when it is midnight in that time zone.
Unless there is something about the question I don't understand...?
Re:GMT offsets are your friend. (Score:3, Informative)
Re:GMT offsets are your friend. (Score:1)
Plus, you could write a script to change your scripts. Or something.
Re:GMT offsets are your friend. (Score:3, Informative)
Re:GMT offsets are your friend. (Score:1)
##
1 0 0 0 0
MIDNIGHT 0 0 0 0 0
##
sed s/MIDNIGHT/`getmidnight.sh`/
crontab -l
Re:GMT offsets are your friend. (Score:2)
Ya, they don't change that often, but the problem is that some (even in the US) don't change (like Arizona or places nearer to the equator) ever. Others change at different times of the year (daylight savings time begins in most Western European countries a week before it does in North America) or in different directions (ie, southern hemisphere summer is northern hemisphere winter). These things would just make it a pain.
It seems like you could run some cron job ev
Re:GMT offsets are your friend. (Score:1)
(E&OE ;-)
Please, geeks of the world (Score:5, Informative)
Re:Please, geeks of the world (Score:2)
easy solution (Score:2)
There's a tiny amount of overhead for running the check script at times that aren't local midnight, but that should be completely negligible.
Re:easy solution (Score:2)
I forsee myself having to do stuff at 3pm GMT or 1pm EDT or 2pm MDT.
Re:easy solution (Score:2)
No, just a simple test:
correction... (Score:4, Informative)
However, there's another simple solution. Again, based on the fact that there's really only two times that can be local midnight. Simply run a script like this at the earlier of the two times: Note that hacking cron to respect timezones will result in the same bug as my earlier approach. So, this approach is really the cleanest I can see.
Re:correction... (Score:2)
-s
Re:correction... (Score:2)
No, that's why I made the time zone an argument to the script. So, in the crontab, you just pass the appropriate zone name when you call the script.
Re:correction... (Score:2)
"Midnite"? (Score:1)
People are still working at midnight (Score:2)
You may want to consider your use of midnight as a good time to run scripts.
Many people are still awake at this time, perhaps working from home, trying to beat a deadline, etc. Cron jobs using resources at this time could be frusturating, making a long night even longer.
You may want to consider moving jobs to 2 or 3 AM instead.
TZ is your friend (Score:5, Informative)
i.e.
Re:TZ is your friend (Score:2)
I can have cron do a job way before midnite, but if I had to have a job run in all 24 time zones, it could get ugly in running many at jobs at many times.
It'd be great if there was somethign clean to put in cron as...
0 0EDT * * *
I might have to write that a day.
hacking cron won't work (Score:2)
I think the best approach is the one I outlined here [slashdot.org]. Run at the earliest time that might be midnight, and if it's not yet midnight, sleep till it is.
Daylight Savings Time (Score:1)
Re:Daylight Savings Time (Score:2)
I might also add that Midnight isn't as late as it used to be. Push cron jobs past midnight by an hour or two. System could still be busy at midnight depending on the place you work at. At a
virtual servers (Score:2)
Re:virtual servers (Score:2)
This approach assumes that the tasks you want to perform are practical inside a chroot or jail.
DateTime.pm is your friend (Score:4, Informative)
It's really a lifesaver, here is a link DateTime.pm [cpan.org]
Re:DateTime.pm is your friend (Score:2)
modded cron (Score:1)
How about a "helper" program? (Score:2)
You'd need only one main config file, looking something like:
00:00 script.ut
16:00 script.pmt
19:00 script.edt
(blah, blah, blah)
And each individual script could h
The real problem... (Score:1)
Seems to me that the real problem is determining how to spell midnight. 8)
Use NQS (Score:1)
NQS code should be available on the net - the source was released by NASA a long time ago.