Author Topic: server time : timezone not applied  (Read 2193 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
server time : timezone not applied
« on: March 31, 2022, 07:12:16 AM »
Hello,
I defined the timezone of my server to "Europe/Paris", so UTC+2
I Also defined timezone in /usr/local/php/php.ini and /usr/local/cwp/php71/php.ini

When I execute a php script that logs date and time, data are correct. Script executed at 09:00 records 09:00 in the log.
But the date of the modified .log file is still UTC (09:00-2 => 07:00).

Is it normal ? I think no.... How to correct that ?

Thanks for your help
David

Offline
****
Re: server time : timezone not applied
« Reply #1 on: March 31, 2022, 10:28:36 AM »
Not sure what you mean by modified log file, could you please elaborate?
Google Hangouts:  rcschaff82@gmail.com

Offline
*
Re: server time : timezone not applied
« Reply #2 on: April 01, 2022, 07:02:11 AM »
I mean when the script is executed and the .log file content updated, the date and time of the log file are UTC date and time (ie 07:00) ; not UTC+2 (ie 09:00) as defined in server timezone settings

Offline
****
Google Hangouts:  rcschaff82@gmail.com

Offline
*
Re: server time : timezone not applied
« Reply #4 on: April 04, 2022, 05:15:32 PM »
It is not the date and time of the log entries BUT the date and time of the log file that is not correct.
When a script is scheduled to run at 13:00 (UTC+2)





the log file time is 11:00




I have yet set the time zone on the server to UTC+2, also in the stipulated php.ini files ( /usr/local/php/php.ini and /usr/local/cwp/php71/php.ini)


Offline
****
Re: server time : timezone not applied
« Reply #5 on: April 05, 2022, 04:55:04 AM »
According to what your showing, the Cron Job is running as UTC time instead of your local time.  By chance is your system a VSP running OpenVZ?  From Shell run "date" command to get the system time (which is normally used for cron).
Google Hangouts:  rcschaff82@gmail.com

Offline
*
Re: server time : timezone not applied
« Reply #6 on: April 05, 2022, 05:21:43 AM »
No VSP running OpenVZ. It's a vmware cloud VM.
When I type "date" on the vm (not hypervisor because I don't have any access) from SSH , the right time is displayed....

Offline
****
Re: server time : timezone not applied
« Reply #7 on: April 05, 2022, 05:38:59 AM »
Try restarting the crond service  ( systemctl restart crond ).  It could be that it's still using UTC because the system has not been restarted since setting the timezone
Google Hangouts:  rcschaff82@gmail.com

Offline
*
Re: server time : timezone not applied
« Reply #8 on: April 05, 2022, 07:08:03 AM »
already rebooted several times....

Offline
**
Re: server time : timezone not applied
« Reply #9 on: April 05, 2022, 11:28:03 AM »
if this is a centos distro, try this:
https://linuxize.com/post/how-to-set-or-change-timezone-on-centos-7/

If this doesnt help. Try removing the cronjob from the panel and add it manually through the command line "crontab -e". This will make the cron run as root

also confirm your issue by manually checking the "modified time" with an FTP dedicated client or through the command line.
also confirm in the cron logs what time the cron is running (/var/log/cron)

you will need to come at this from several angles to confirm/fix your issue.
« Last Edit: April 05, 2022, 11:39:17 AM by iraqiboy90 »