How do I set a time zone for a crontab?

Solution 1:

you can set the variable TZ in /etc/default/cron. but this is the timezone for all crontabs.

another alternative is using fcron. the documentation shows an option to set the timezone in each crontab.

Solution 2:

Some cron installations use CRON_TZ to set the per-user interpretation of the crontab times.

Here's part of man 5 crontab on Centos 7:

The CRON_TZ variable specifies the time zone specific for the cron table. The user should enter a time according to the specified time zone into the table. The time used for writing into a log file is taken from the local time zone, where the daemon is running.

Default Debian uses a patched vixiecron, (per https://wiki.debian.org/cron) and does not support per-user time zone functionality. If you set a variable in the crontab, it passes to the child jobs, but does not affect the TZ of the parent cron job. Debian has a 'cronie' package in experimental that supports the CRON_TZ functionality.