Crontab for different ime zones
Late entry to this thread, but... I thought I had found an answer to this; at present I think I might have been mistaken. My crontab has about a dozen jobs that need to run in TZ=America/New_York, and another dozen that ideally want TZ=Australia/Sydney... the server default is America/Chicago. Given that the DST wobble for Australia/Sydney is not the same as for America/New_York (and given that I am lazy) I wanted ONE crontab that would serve year-round, rather than FOUR crontabs that had to be swapped in and out all the time (even if that could be done by a cron job). I thought I had found a solution - simply insert a line TZ=America/New_York before the US jobs, and TZ=Australia/Sydney before the Australian ones. A final statement to return TZ to sever default would be optional. I checked that TZ changes worked, by adding a cron job (for testing purposes) under each TZ declaration, of the form TZ=America/New_York * * * * * date /home/mysite/public_html/tmp/log.txt 21 and TZ=Australia/Sydney * * * * * date /home/mysite/public_html/tmp/log.txt 21 Sure enough, every minute, cron would dutifully change TZ to NY and change again to Sydney. There would be two datestamps in log.txt - one would show current US/NY time, one would show current Australia/Sydney time. Oddly they would appear in REVERSE order in the output file (Sydney first, then NY). PROBLEM: If I run a very simple PHP script after each TZ declaration - for example, one that writes date(Y-m-d H:i e) to the same log file - the PHP script returns the server default timestamp (US/Chicago). So the script does not 'see' the TZ (that is not a problem since my work scripts don't have any internal time dependencies - the only time dependency is the START time). Also, if I time the script as if cron is actually 'seeing' Sydney time, the scripts don't execute as expected. Example: it is currently 1:45 pm Sydney time. If I change TZ=Australia/Sydney * * * * * date /home/mysite/public_html/tmp/log.txt 21 to TZ=Australia/Sydney * 13 * * * date /home/mysite/public_html/tmp/log.txt 21 cron will NOT run the script... I bet it will wait until 13:00 CHICAGO time. I have a feeling that I am missing something relatively simple - at which point my dream of a super-cron will be realised and the stupidity of DST can be ignored (as it ought to be... ). I also bet that someone else has worked this out already, somewhere in the internets tubes... but i have been unable to find it. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Crontab for different ime zones
On Sat, 2009-05-23 at 23:41 -0600, Tim Judd wrote: SNIP I propose the following: cron itself has no concept of timezone. it is 'date' that is picking up TZ and reporting as such. Cron's job is so simple is that it wakes up each minute to see if it has work to do, regardless of timezone, or anything else. Yep - I understood that, Tim. Thew issue seems to be that cron pays no attention to TZ declarations that happen AFTER it wakes up - cron does not parse the job times using the new TZ. The thing I am struggling with is that 'date' picks up the changes imposed by 'TZ=', but then 'cron' parses the next line as if the job times are interpreted using the server's default TZ. I've tried using 'CRON_TZ=' as well as, and instead of, 'TZ=' - to no avail. What I thought ought to happen is this: * 'cron' wakes up; * 'cron' works through the crontab line by line; * at line 1 cron changes the TZ to America/NY; * at line 2 cron reads the job time in the context of having just been told that it's operating in the NY timezone (thus 45 13 * * * is 1:45 pm NY time); . . . * at line 15 cron is told to change the TZ to Australia/Sydney; * from line 14 onwards, 45 13 * * * is 1:45 pm SYDNEY time. . . . and so on. It seems that cron behaves as if it forgets $TZ at each newline within a given cron instance. The silly thing is, with all the time I've wasted pursuing this wild goose I could have built the required four crontabs, and written the script to swap them in and out on the appropriate dates. (Or I could have spent $100 and bought a shared-hosted server space to do the Australian-TZ stuff and given it sufficent permission to store the resultant data in y primary mySQL db...) Still, I think it's worth persevering with. I'm certain it can be done. You might want to try some other determining factor, such as a shell builtin. Good luck. Cheers ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Crontab for different ime zones
On Sun, 2009-05-24 at 18:45 -0600, Tim Judd wrote: How about a jail for America/NY, and a jail for AU/Sydney? that might work. --TJ That's a good solution, but I am still somewhat puzzled by cron's behaviour relative to what I expected from the man page. From the man page for crontab(8): In order to provide finer control over when jobs execute, users can also set the environment variables CRON_TZ and CRON_WITHIN. The CRON_TZ variable can be set to an alternate time zone in order to affect when the job is run. Note that this only affects the scheduling of the job, not the time zone that the job perceives when it is run. If CRON_TZ is defined but empty (CRON_TZ=), jobs are scheduled with respect to the local time zone. Problem is, CRON_TZ just doesn't work as written above. If you insert CRON_TZ=America/New_York and then write the * * * * * (schedule) to reflect NY time (say), but your server time is Chicago, cron ignores the CRON_TZ definition. Here's a CRONTAB extract which provides a good example of the odd behaviour: # - sample crontab # change tz and cron_tz to America/NY TZ=America/New_York CRON_TZ=America/New_York # check that timezone change 'stuck' (commented out except for testing) * * * * * printf CRON_TZ is now $CRON_TZ. Now doing US\n /home/targetdir/public_html/tmp/log.txt 21 * * * * * date /home/targetdir/public_html/tmp/log.txt 21 # Now, change both TZs to Australia/Sydney TZ=Australia/Sydney CRON_TZ=Australia/Sydney # check that timezone change 'stuck' (commented out except for testing) * * * * * printf CRON_TZ is now $CRON_TZ. Now doing Australia\n /home/targetdir/public_html/tmp/log.txt 21 * * * * * date /home/targetdir/public_html/tmp/log.txt 21 # - end sample crontab The result of that will be Mon May 25 11:02:01 EST 2009 CRON_TZ is now Australia/Sydney. Now doing Australia Sun May 24 21:02:01 EDT 2009 CRON_TZ is now America/New_York. Now doing US 'date' is right, and $CRON_TZ changes as expected, but has no effect in cron. One other thing strikes me as odd: the output file is in reverse order to the crontab. If changes to CRON_TZ actually worked as written, then one would need to verify that the changes propagated 'downstream' from the variable declaration. It's not that output is being written to the top of the outfile though - output in subsequent minutes is APPENDED to the outfile. And now for the big DUH, I'm an idiot moment - apparently FreeBSD, Fedora and Ubuntu don't have CRON_TZ support built in. It's gotten to the stage where you have to be wary of what you find in external man pages... Cheers GT ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: What's wrong with this picture?
I'm pretty sure you could set up a filter on Mr Puchar's name; it's not hard. That said, I just read a sample of his posts (not all of them), and the ones I looked at didn't appear to be 'off-topic' and would probably have passed muster from any reasonable moderator (aye, but there's the rub: who gets to define 'reasonable'?). The phrase You're fast to agree with our resident M$ troll when he argues against government control of anything, even of protecting the population from a 'free' market that's happy to profit by poisoning people in body or mind stands in stark contrast to your exhortation that he focus [his] energies on things you do know something about. I'm against moderation, for the simple reason that people who want to be moderators will bring their baggage to their efforts (like your corporations kill the environment and are protected by the 'free' market stuff, or my government is the problem, full stop: Caedite Eos stuff). That is to say, anyone who wants to be a moderator ought to be disqualified from doing so (that goes for anyone who wants to control anyone else). In sum, I double-plus unbellyfeel groupthink. Cheerio GT (No Microsoft products were used in the creation of this message - MS would not exist but for its government contracts ... MSFT is a distinctly NON-'market' entity). On Sun, 2009-05-31 at 16:00 +1000, Ian Smith wrote: On Sat, 30 May 2009, freebsd-questions-requ...@freebsd.org wrote in freebsd-questions Digest, Vol 260, Issue 31 [..] 1. Fw: UK Currency Symbol in 7.2 Console (Graham Bentley) 2. Re: find and searching for specific expression in files (Mel Flynn) 3. Re: find and searching for specific expression in files (Valentin Bud) 4. Re: MIME attachments in mbox files (Ian Smith) 5. Re: Canon printer and TurboPrint (Jerry) 6. FreeBSD 7.0-RELEASE-p12 bind9 log files not found (Prokofyev Vladislav) 7. GSM to Serial Converter (Exemys) 8. Re: FreeBSD 7.0-RELEASE-p12 bind9 log files not found (Mel Flynn) 9. Re: FreeBSD 7.0-RELEASE-p12 bind9 log files not found (Michael Powell) 10. Re: GSM to Serial Converter (Kevin Kinsey) 11. Re: Canon printer and TurboPrint (cpghost) 12. Re: FreeBSD 7.0-RELEASE-p12 bind9 log files not found (Prokofyev Vladislav) 13. Re: Canon printer and TurboPrint (Wojciech Puchar) 14. Re: Fresh install 7.2-RELEASE i386, X won't start (Wojciech Puchar) 15. Re: Failure to get past a PCI bridge (Ian Smith) 16. Re: What is this forum for? (Wojciech Puchar) 17. Re: Stable Mail Server And Web Mail (Wojciech Puchar) 18. Re: What is this forum for? (Wojciech Puchar) 19. Re: FreeBSD 7.0-RELEASE-p12 bind9 log files not found (Mel Flynn) 20. Re: On the need for moderated questions lists (Wojciech Puchar) 21. Re: Competition law (was Re: Canon printer and TurboPrint) (Wojciech Puchar) 22. RE: On the need for moderated questions lists (Wojciech Puchar) 23. Re: Canon printer and TurboPrint (Wojciech Puchar) 24. Re: MIME attachments in mbox files (Wojciech Puchar) 25. Re: Canon printer and TurboPrint (Wojciech Puchar) 26. Re: On the need for moderated questions lists (Wojciech Puchar) 27. Re: Remotely edit user disk quota (Wojciech Puchar) 28. Re: find and searching for specific expression in files (Wojciech Puchar) 29. Re: Stable Mail Server And Web Mail (Mel Flynn) 30. Re: Software creating karaoke from mp3 files (Wojciech Puchar) 31. Re: Greylisting and new posters (Wojciech Puchar) 32. Re: find and searching for specific expression in files (Wojciech Puchar) 33. Re: Canon printer and TurboPrint (Wojciech Puchar) 34. Re: Canon printer and TurboPrint (cpghost) 35. Filter request Re: GSM to Serial Converter (Wojciech Puchar) 36. Re: Stable Mail Server And Web Mail (Wojciech Puchar) Woj, 20 out of 36 messages, over 55% of all these messages, are by you. Having been very busy in recent weeks, I'd accumulated about 24 digests unread that I ploughed through yesterday, many of which featured over 50% of messages either from you, or from silly people reacting to you, whose ranks I must join for just this once. I gather that you're hoping to prove that without moderation - as we've enjoyed for 11 years that I've experienced - if you keep on flooding the list with so much off-topic crap, then we'll be forced into accepting your wish for the list to be controlled, post by post, by some poor bastard who needs to be awake 24/7/365 and has little else of a life. I don't have the sort of free time (nor apparent need) that you have to try fashioning this sometimes-helpful list after my own wishes, which is why I get digests, posting occasionally where I think I can maybe help. I'm also subscribed to about a dozen other FreeBSD lists that in total deliver not many more