afridy — 2012-08-18T01:50:15-04:00 — #1
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
dklynn — 2012-08-18T07:30:20-04:00 — #2
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).
afridy — 2012-08-18T07:38:55-04:00 — #3
yes, i understand, ill come back with the feedback
afridy — 2012-08-23T01:50:41-04:00 — #4
Your answer rockes!!!
0 23 * * * php -q /home/....../process.php
works charm at 8am in saudi arabaia
dklynn — 2012-08-23T03:43:04-04:00 — #5
No worries, mate, just watch the Daylight Savings Time changes in SA and US.
snickn — 2012-08-23T06:53:50-04:00 — #6
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.
dklynn — 2012-08-24T07:58:54-04:00 — #7
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).
snickn — 2012-08-24T08:01:32-04:00 — #8
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.
ralphm — 2012-08-24T10:05:38-04:00 — #9
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.
dklynn — 2012-08-24T17:48:47-04:00 — #10
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.