From owner-freebsd-questions@FreeBSD.ORG Sun May 24 04:17:39 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30D041065673 for ; Sun, 24 May 2009 04:17:39 +0000 (UTC) (envelope-from catch.all@marketmentat.com) Received: from mars.hostupon.com (mars.hostupon.com [67.228.194.3]) by mx1.freebsd.org (Postfix) with ESMTP id 10E0D8FC1A for ; Sun, 24 May 2009 04:17:39 +0000 (UTC) (envelope-from catch.all@marketmentat.com) Received: from [58.165.2.20] (helo=[192.168.1.100]) by mars.hostupon.com with esmtpsa (SSLv3:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1M84fV-0008Oq-Ie for freebsd-questions@freebsd.org; Sat, 23 May 2009 22:46:52 -0500 From: GT To: freebsd-questions@freebsd.org In-Reply-To: Content-Type: text/plain Date: Sun, 24 May 2009 13:46:35 +1000 Message-Id: <1243136795.29198.42.camel@ubuntu> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - mars.hostupon.com X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - marketmentat.com X-Source: X-Source-Args: X-Source-Dir: Subject: Crontab for different ime zones X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Sarah.Varney@marketmentat.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 May 2009 04:17:39 -0000 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 2>&1 and TZ=Australia/Sydney * * * * * date >> /home/mysite/public_html/tmp/log.txt 2>&1 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 2>&1 to TZ=Australia/Sydney * 13 * * * date >> /home/mysite/public_html/tmp/log.txt 2>&1 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.