crontab entries for different time zones?

Ask a Question related to Linux / Unix Administration, Design and Development.

  1. #1

    Default crontab entries for different time zones?

    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! [url]http://www.smart.net/~hymowitz[/url] [email]hymie@lactose.smart.net[/email]
    ================================================== =============================
    hymie! Guest

  2. Similar Questions and Discussions

    1. Wotrld Time Zones
      Hi folks. I want to build a web page which contains a map that will display the (global) location of where each family member / school / office etc...
    2. scripting crontab entries
      I want to be able to update a user's crontab from a script. tabs in /var/cron/tabs carry a warning that the file should not be edited directly, so...
    3. #21965 [Fbk->NoF]: gettext uses entries out of different files at the same time
      ID: 21965 Updated by: sniper@php.net Reported By: thorsten dot kussler at communardo dot de -Status: Feedback...
    4. #21965 [Opn->Fbk]: gettext uses entries out of different files at the same time
      ID: 21965 Updated by: sniper@php.net Reported By: thorsten dot kussler at communardo dot de -Status: Open...
    5. #21965 [Fbk->Opn]: gettext uses entries out of different files at the same time
      ID: 21965 User updated by: thorsten dot kussler at communardo dot de Reported By: thorsten dot kussler at communardo dot de...
  3. #2

    Default Re: crontab entries for different time zones?

    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 the
    main job (only needed to run in November and April), and rewrites the crontab
    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 [email]dagon@dagon.net[/email] <http://www.dagon.net/>
    *doesn't get to wear his BOFH hat often enough*
    Mark Rafn Guest

  4. #3

    Default Re: crontab entries for different time zones?

    On 2004-06-02 20:37, hymie! wrote:
    > 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! [url]http://www.smart.net/~hymowitz[/url] [email]hymie@lactose.smart.net[/email]
    > ================================================== =============================
    Cron will only use one timezone, at last what I beleive.

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

    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
    Birger Blixt Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139