Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Cronjob that updates cached file and takes about 1.5 minutes

Discussion in 'Workarounds and Optimization' started by meteocaldas, Sep 25, 2016.

  1. meteocaldas

    meteocaldas Registered

    Sep 25, 2016
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Website Owner

    In my site and using cpanel, I have several cronjobs that run several php files.
    Each of these php file, creates a cached file (the very first time it runs or there is no cached file)
    and the next times, it updates the existing cached file with new values.

    All cronjobs are working well, but I am having an isuue with one of them.
    This cronjob I am talking about, takes about 1.5 minuts to update the cached file because it gets the new values from different sources and takes about 2.5 seconds for each of the 30 sources.
    It does everything accordingly and the update is perfect but the isuue is...

    If by coincidence, anyone requests that webpage during the update process, then he has to wait a long time (up to 1.5 minutes) before the results are displayed.
    The problem is that the cached file is deleted and then replaced by tha updated cached file, but only after all the values have been collected.
    Of course I get lots of complaints for this borring delay and I have been wondering all possible solutions for this.

    The solution that looks the esasiest one, would be this one:
    - the cached file stays in use while it is beeing updated by means of a temp cache file.
    - after this temp file is complete with all the new updated values, then it replaces the current cached file.

    Is this possible?

    Thanks in advance.
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Apr 11, 2011
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator

    You may receive more user-feedback to this type of question via a third-party resource such as StackOverflow, as it seems to relate more to the coding of the script as opposed to a cPanel/WHM feature.

    Thank you.
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice