how to run cron jobs on GMT not local time?

Solution 1:

Not all versions of cron support running jobs using a time zone other than the system's.

If yours does, it's likely that the specification should be TZ=GMT or TZ=UTC (without the angle brackets). In some cases, the variable would be CRON_TZ.

The best thing to do is check the documentation specific to the particular system. See man 5 crontab.

Solution 2:

If your local time is Europe/London. Then:

crontab -e    # or 'cru' on some machines
>>>
# Run COMMAND at 03:15am UTC every morning
15 3 * * * [ "$(date +\%z)" = "+0000" ] && COMMAND
15 4 * * * [ "$(date +\%z)" = "+0100" ] && COMMAND
<<<

Another example:

If your regular time is +0500 shift of UTC, and your seasonal time is +0600 shift of UTC. Then add +5 to all of the hours specified in above example. This means being run at 08:15am and 09:15am of your local time respectively. So your modified cron lines would then look like this:

crontab -e    # or 'cru' on some machines
>>>
# Run COMMAND at 03:15am UTC every morning
15 8 * * * [ "$(date +\%z)" = "+0500" ] && COMMAND
15 9 * * * [ "$(date +\%z)" = "+0600" ] && COMMAND
<<<

[EDIT] Be sure to \ escape any percent % characters in your crontab file. As crontab interprets them to be a newline seperator. e.g. % --> \%.