SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    960
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    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
    Code:
    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.

    Code:
    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

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    960
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn View Post
    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

  4. #4
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    960
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn View Post
    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
    Your answer rockes!!!

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

    works charm at 8am in saudi arabaia

    Thanks dklynn

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    No worries, mate, just watch the Daylight Savings Time changes in SA and US.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  6. #6
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn View Post
    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.
    Comcure does independent, off-site website backups just for the webmaster
    Full API. Daily Snapshots. Backup via FTP, FTP over TLS or SFTP.
    Storage Pods in USA, Europe and Asia to come. Backup to the closest one.

  7. #7
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  8. #8
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn View Post
    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.
    Comcure does independent, off-site website backups just for the webmaster
    Full API. Daily Snapshots. Backup via FTP, FTP over TLS or SFTP.
    Storage Pods in USA, Europe and Asia to come. Backup to the closest one.

  9. #9
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,592
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by snickn View Post
    the cronjob will automatically adapt to that one hour change
    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.

  10. #10
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •