On my site and using cpanel, I have several cronjobs that run multiple php files. Each of these cronjobs creates a cached file where the site will fetch information. All cronjobs are working fine, but I'm having a problem with one of them. This cronjob that I'm talking about takes about 1.5 minutes to update the cached file because it will pick up values from multiple sources and this process is time consuming. It does everything accordingly and the update is perfect, but ...
The problem is that the cached file is deleted as soon as cronjob is started and the new cache file will only appear after all values have been collected (1.5 minutes later). Therefore, if a user of the site has the bad luck to consult the page that depends on that cache during the update process, it will end up giving up because it does not seem to work.
I have tried solutions but not success.
The solution that seems to me the best, would be this: - The cached file remains in use while a new cache is being created through a temporary file. - When this temporary file is finished with all new values already updated, it only replaces the current cached file.
Can anyone give me a hint how to get this?