I have a cronjob which is executes every day at 9:00 AM of UTC-Time. I'm in GMT+1 so it executes at 10:00 AM local time. When there is the timezone change (to daylight saving time, DST), the cronjob executes still at 9:00 AM of UTC-Time but at 11:00 AM local time. But I want it always to execute at 10:00, no matter of summer time or not. How do I do that?
This will likely depend on your OS and it's implementation of
cron. This is not possible in the most popular cron implementation,
vixie/isc cron. From the
LIMITATIONS The cron daemon runs with a defined timezone. It currently does not support per-user timezones. All the tasks: system's and user's will be run based on the configured timezone. Even if a user specifies the TZ environment variable in his crontab this will affect only the commands executed in the crontab, not the execution of the crontab tasks themselves.
Expanding on @Cyrus answer this is what I did:
I made a script which checked a UTC offset:
#!/bin/bash export TZ=":US/Eastern" if [ "$(date +%z)" == "$1" ]; then shift exec $@ fi
Then I add two crontab entries each for the offset I want:
0 8 * * * run-only-with-tz.sh -0400 place_your_command_here 0 9 * * * run-only-with-tz.sh -0500 place_your_command_here