Bips
Bips

Reputation: 133

Cron Jobs is not following WHM/Server timezone

I have a dedicated cloud server from vultr. In my WHM, I have set my server timezone to Asia/Kolkata (Indian Time). And also in my cPanel (through multiPHP INI Editor), I have set my timezone to Asia/Kolkata.

To test my timezone, I have this in a php file -

date_default_timezone_set("Asia/Kolkata");
$script_tz = date_default_timezone_get();
if (strcmp($script_tz, ini_get('date.timezone'))){
   echo 'Script timezone differs from ini-set timezone.';
} else {
   echo 'Script timezone and ini-set timezone match.';
}

So I can see that my script timezone and ini-set timezone is same, it matched. Also phpinfo() shows my date/time zone as Asia/Kolkata

BUT

Now, I want to run a cronjob everyday at midnight (Asia/Kolkata) and my cronjob settings are -

 Min |Hour | Day  | Month | Weekday |  Command
-----+-----+------+----- -+---------+------------------------------------------+
 0   |  0  |  *   | *     |   *     | /usr/local/bin/php /home/namehere/public_html/cron_test.php

The above cron run well but not at my desired timezone (Asia/Kolkata). I think it is running on UTC or something.

Why even after my WHM/Server timezone is Asia/Kolkata, cronjob is not following it? Where I am doing wrong. Please guide me to fix the issue.

Upvotes: 0

Views: 333

Answers (1)

FAEWZX
FAEWZX

Reputation: 1029

What the command date outputs in SSH console ?

Copy timezone file.

cp /usr/share/zoneinfo/Asia/Kolkata /etc/localtime

Upvotes: 0

Related Questions