Strange CPanel Crone Timing issue

Hai folks,

i am running a cron job from saudi arabia.
the time zone of the server has correctly been updated using .htaccess

SetEnv TZ Asia/Riyadh

the php date() shows the saudi arabaian time correctly.

Below is the cron job i am running. I want it to run every day 8am.

0 	8 	* 	* 	* 	php -q /home/xxxxx/public_html/xxxx/process.php

Problem is, the above is not running at 8am here. it runs at evening 5 pm.
strange. Please help to fix this issue :slight_smile:

afridy,

With what you’ve said, the server’s time is what’s being used for the CRON job, not the time you set for cPanel and your website. CRON is a feature of the server and (I believe) must run on the server’s clock, not yours. Therefore, since you’re 9 clock hours behind the server, run at 2300 (23), not 0800 (8).

This is a common problem with servers in time zones other than the webmaster or target audience. I’m in NZ and host in the US so there’s not only a time zone difference but a different schedule for daylight savings time for me to deal with (as well as NZ changing their DST start and stop dates).

Regards,

DK

Thank dklynn,
yes, i understand, ill come back with the feedback :slight_smile:

Your answer rockes!!!

0 23 * * * php -q /home/…/process.php

works charm at 8am in saudi arabaia :slight_smile:

Thanks dklynn

No worries, mate, just watch the Daylight Savings Time changes in SA and US.

Regards,

DK

Actually, per the cron man page, it’ll adjust for daylight savings automatically.

Daylight Saving Time and other time changes
Local time changes of less than three hours, such as those caused by
the start or end of Daylight Saving Time, are handled specially. This only applies to jobs that run at a specific time and jobs that are run with a granularity greater than one hour. Jobs that run more frequently are scheduled normally.
If time has moved forward, those jobs that would have run in the interval that has been skipped will be run immediately. Conversely, if timehas moved backward, care is taken to avoid running jobs twice.

Time changes of more than 3 hours are considered to be corrections to the clock or timezone, and the new time is used immediately.

snickn,

Please read the posts above. Both the OP and I live in countries other than where the host is located. In general, countries do not conform to the same change dates for DST so calculating the clock differential between two locations can be critical (to provide “local time”). While the CRON might be adjusted for the server, it can’t accommodate for two different time zones and the differential between them (on a shared server).

Regards,

DK

You told OP to make sure to change the cron for daylight savings. However, assuming the server is in a time zone that has daylight savings then the cronjob will automatically adapt to that one hour change, hence if they took your advice and logged back in and changed the time back/forward an hour they would be going two hours.

Doesn’t matter where they are, matters where the server is, and whether that time zone has daylight savings, being it’s most likely they are in daylight savings areas…this is a safe assumption.

But while the server location time may jump ahead an hour, the OP’s location time might jump back an hour (as daylight savings begin)—or vice versa—so suddenly there is a two hour difference.

Ralph,

Finally, someone who understands elementary math and is not a member of the Flat Earth Society! Thanks for helping out … but I’m sure everyone else understands as afridy did.

Regards,

DK