问题原文
原帖链接 · Florent · CC BY-SA 3.0
I use shared hosting at Bluehost and changed the default date.timezone to UTC in my php.ini. Everything works fine with my PHP script and date() return the UTC time as expected.
The problem occurs with the crontab, because when I enter a cron job to be executed every Monday at 00:15 AM UTC with the following line :
15 0 * * 1 php /home2/mywebsite/public_html/php/myscript.php
Then the script is not executed at 00:15 AM UTC time but at 00:15 AM UTC-6 which is Western America I guess. For this reason I need to set it at 06:15 PM of the day before, which is Sunday, to have it executed at Monday at 00:15 AM UTC:
15 18 * * 0 php /home2/mywebsite/public_html/php/myscript.php
I asked their support but they said they cannot help with the crontab. For them it just work.
Is it related to the shared hosting and is there a possibility to change this so that crontab service use my php.ini timezone setting ?
已采纳解答
原帖链接 · Florent · CC BY-SA 3.0
I've found that after I changed my php.ini timezone setting to UTC the Bluehost shared hosting cron service was still using the MDT (Mountain Daylight Time) timezone which has an offset of -6 hours. This is probably due to the shared hosting as stated by @dan in the comments, and there is nothing to change that but to switch to a dedicated hosting.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
