1

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 ?

  • 1
    @Florent Cron uses the local time of the server. On a shared hosting account, you won't be able to change that. You could find the exact time difference and timezone using a script though. Once you know what that is, you can either continue to pad the time with the difference as you have been, or contact support and request that they set the system's time (it really shouldn't be 15 minutes off UTC anywhere). – dan Jul 17 '17 at 4:09
  • 1
    I don't think it is 15 minutes off, it looks like the example is supposed to run 15 minutes after midnight, and he has to set it exactly 6 hours off. – Stephen Ostermiller Jul 17 '17 at 9:33
  • 1
  • 1
    Thanks for all the useful comments! I've found that Bluehost shared hosting cron service use MDT (Mountain Daylight Time) timezone which has an offset of -6 hours. This is probably due to the shared hosting as stated by @dan and there is nothing to do to change that. Thanks! – Florent Jul 17 '17 at 11:28
  • 1
    @Florent NP. Feel free to answer the question based on your comment above and then accept it when you can. That way it will mark the question as answered and the community will know, and you'll earn some reputation points here. Thanks. – dan Jul 18 '17 at 1:49
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.