Cron job time zone on shared hosting

  • Answered
I'm trying to set up a cron job on my shared hosting account. I noticed, however, that the server is set to PST and that I must alter the cron job times to reflect that.

Is there any way to work around this? I'm assuming that because I'm on a shared hosting account, I am at the mercy of the timezone settings for the shared server.
Hello cwang114, and thanks for the great question! It is possible to adjust the time zone for your cron job on Shared Hosting. However please note that the time you are choosing for the cron job to actually run, will be in the local server's time zone. So for instance I just setup a test to verify this method works, and ran it on an East Coast server at 12:53PM EDT. The resulting time-stamp in my test file, used the time zone that I had exported though so it displayed 9:53AM PDT. If this was your current cron job:

date > /home/userna5/DATE_TEST

To have it use a Pacific time zone you simply append this part in red to the beginning:

export TZ='America/Los_Angeles'; date > /home/userna5/DATE_TEST

The TZ variable controls which time zone should be used for that current command, and you can view a list of TZ time zones from Wikipedia to get the correct one in your case. Hope that answered your question, please let us know if you run into any issues or if you have any further questions at all! - Jacob