Linux – How to configure cron to run jobs using specific timezone times

cronlinuxredhat

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

Best Answer

Sure, you can. Try this:

0 9 * * * job1
TZ=Asia/Hong_Kong
0 10 * * * job2