crontab entries for different time zones?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix administration > crontab entries for different time zones?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    crontab entries for different time zones?  
hymie!


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-02-04 09:51 PM

Greetings.

A problem has arisen at my workplace.  We are near Baltimore, MD,
GMT-5/GMT-4, and we have a customer in Honolulu, HI , GMT-10.

I would like to run a cron job on my Solaris 9 box every day at 0800 HST.
The Solaris box has EST5EDT as its default time zone.  Unfortunately,
half of the year, 0800 HST = 1400 ET, and the other half,
0800 HST = 1300 ET.

Is there a way that I can somehow attach a TZ variable to an individual
crontab entry?

The only thing I can think of that would work is to run my job every
day at 1300 EST/EDT , and start my script with

if [ `date +%Z` = "EDT" ]
then
sleep 3600
fi

but the actual job is just a mv , and I was hoping to avoid building
a script around it.

Thanks.

hymie!          http://www.smart.net/~hymowitz          hymie@lactose.smart.
net
 ========================================
====================================
===





[ Post a follow-up to this message ]



    Re: crontab entries for different time zones?  
Mark Rafn


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-02-04 09:51 PM

hymie! <hymie@lactose.smart.net> wrote:
>I would like to run a cron job on my Solaris 9 box every day at 0800 HST.
>The Solaris box has EST5EDT as its default time zone.  Unfortunately,
>half of the year, 0800 HST = 1400 ET, and the other half,
>0800 HST = 1300 ET.
>Is there a way that I can somehow attach a TZ variable to an individual
>crontab entry?

Not in the way you want.  The TZ var can be set in an entry, but it's
passed through to the job, and has no effect on when the job runs.

>The only thing I can think of that would work is to run my job every
>day at 1300 EST/EDT , and start my script with
>if [ `date +%Z` = "EDT" ]
>then
>  sleep 3600
>fi
>but the actual job is just a mv , and I was hoping to avoid building
>a script around it.

Another option would be to just edit the crontab in April and November.  If
you want to get tricky, you can write a cron job which runs 2 hours before t
he
main job (only needed to run in November and April), and rewrites the cronta
b
if the DST has changed.

Or just move it to 1000 ET, which is the middle of the night in Hawaii and
they won't care about the one hour difference.
--
Mark Rafn    dagon@dagon.net    <http://www.dagon.net/>
*doesn't get to wear his BOFH hat often enough*





[ Post a follow-up to this message ]



    Re: crontab entries for different time zones?  
Birger Blixt


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-04-04 09:53 PM

On 2004-06-02 20:37, hymie! wrote:[vbcol=seagreen]
> Greetings.
>
> A problem has arisen at my workplace.  We are near Baltimore, MD,
> GMT-5/GMT-4, and we have a customer in Honolulu, HI , GMT-10.
>
> I would like to run a cron job on my Solaris 9 box every day at 0800 HST.
> The Solaris box has EST5EDT as its default time zone.  Unfortunately,
> half of the year, 0800 HST = 1400 ET, and the other half,
> 0800 HST = 1300 ET.
>
> Is there a way that I can somehow attach a TZ variable to an individual
> crontab entry?
>
> The only thing I can think of that would work is to run my job every
> day at 1300 EST/EDT , and start my script with
>
> if [ `date +%Z` = "EDT" ]
> then
>   sleep 3600
> fi
>
> but the actual job is just a mv , and I was hoping to avoid building
> a script around it.
>
> Thanks.
>
> hymie!          http://www.smart.net/~hymowitz          hymie@lactose.smar
t.net
>  ========================================
 =======================================[
/v
bcol]

Cron will only use one timezone, at last what I beleive.

Create a cronjob that run a (write protected) script at the morning your tim
e.

In the script you can try:

#!/bin/sh

TZ=HST
export TZ

at 8 << EOF >/dev/null 2>&1

cd something
mv foo bar
....

EOF

Then your atjob will follow another timezone.

demo :-)

% cat htest
#!/bin/sh

TZ=HST
export TZ

at 8 << EOF

date >/tmp/htest


EOF

% ./htest
commands will be executed using /bin/tcsh
job 1086372000.a at Fri Jun  4 08:00:00 2004
% setenv TZ EST5EDT
% at -l
1086372000.a    Fri Jun  4 14:00:00 2004
%

This example will run the job at 08:00:00 HST whatever the EST5EDT time is.

% zdump EST5EDT HST
EST5EDT  Fri Jun  4 11:30:19 2004 EDT
HST      Fri Jun  4 05:30:19 2004 HST


/bb





[ Post a follow-up to this message ]



    Re: crontab entries for different time zones?  
Jay Lessert


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-09-04 01:06 PM

hymie@lactose.smart.net (hymie!) wrote in message news:<10bs7k5ihfl7041@corp.supernews.com>.
.
> but the actual job is just a mv , and I was hoping to avoid building
> a script around it.

A wrapper is the only correct/robust way to do it.

Might be better to have the wrapper actually check
Hawaii time, and just run it every hour:

TZ=US/Hawaii; export TZ
hour=`date +%H`
if [ $hour -eq 8 ] ; then
mv foo bar
fi

Then in the future when either of the zone definitions change,
the crontab takes care of itself





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 07:18 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register