Setting timezone for cronjobs

Recently, during development of a project I came across with following problem:

I wanted to create cronjob to execute some command in specific time, everyday. By the way, server os was Ubuntu 14.04.2 LTS.

The actual problem was, even if system date-time was set using following command:

sudo dpkg-reconfigure tzdata

the cronjob’s timezone was different from system’s default timezone. That was pretty weird.


Well, after googling a while I figured out a workaround for this problem.

TZ=Asia/Baku 0 1 * * * some_command

That’s it. By the way, TZ stands for timezone.

It turns out that, there is a way to set timezone per cron task:)

Tural Aliyev

I'm traveloholic, musicphile, technoholic, cinephile, workaholic software developer


Subscribe to Tural's Notebook

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!