Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have a system configured in local UK time - so its currently in BST and will be switching to GMT this coming weekend.

There are some reports scheduled with cron that are for users in Hong Kong. As they have no Daylight Savings Time, their clocks are not changing.

So - the plan is, as per usual, to adjust the times of their reports back an hour.

Is there a way to tell cron to run at a specific timezone time, for example run job1 at 9am localtime, run job2 at 10am HK time?

I see from this question that you can specify a timezone in the crontab file, but that seems to affect the timezone of the environment under which commands are run and not the time at which the jobs are run.

Thanks in advance for any tips. Chris

share|improve this question
    
Considered Autosys, but seems overkill for this small annoyance. Currently going for a templated crontab file - expanding GMT08 etc type tokens for the correct time. Still requires a release per cutover, but less error prone –  Chris Kimpton Oct 25 '11 at 14:36

1 Answer 1

Sure, you can. Try this:

0 9 * * * job1
TZ=Asia/Hong_Kong
0 10 * * * job2
share|improve this answer
    
Thanks quanta, I did try that out, but that just means within job2 the timezone is Hong Kong, it still gets triggered at 10am BST. I want it to run at 10am Hong Kong time. –  Chris Kimpton Oct 24 '11 at 17:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.