0

I've configured my timezone on server with timedatectl, e.g.:

timedatectl set-timezone Europe/Budapest

I've put timezone settings to my crontab configuration like these:

CRON_TZ=America/Cancun
0 12 * * *  echo "not scheduled in time"

# or

TZ=America/Cancun
0 12 * * *  echo "not scheduled in time"

# or

0 12 * * *  TZ=America/Cancun echo "not scheduled in time"

But doesn't matter what TimeZone configuration I try to set in the crontab (America/Cancun), the jobs are always scheduled by the timezone configured by the timedatectl (Europe/Budapest). I even restarted the cron service:

sudo service cron restart

I would assume that CRON_TZ or TZ in crontab should add some "independence" to the schedule from the system time configuration.

What am I doing wrong here? Why the schedule in crontab is not relative to the timezone configured by the timedatectl.

I'm using debian on AWS.

elaspog
  • 173
  • 1
  • 1
  • 8

1 Answers1

2

There is no CRONT_TZ on debian.

When you check the man page, man 5 crontab this is what you can find:

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.

What you need to do is to set the time as your timezone defined on the server "Budapest". You can use this online tool to calculate the correct time

https://www.epochconverter.com/timezones

Samuel PE
  • 48
  • 5