Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

update_disk_usage_cron()

Description

Update disk usage for all resources that have not yet been updated or have not been updated in the past 30 days.
Limit to a reasonable amount so that this process is spread over several cron intervals for large data sets.

Parameters

This function accepts no parameters.

Return

boolean|void

Location

include/resource_functions.php lines 6169 to 6204

Definition

 
function update_disk_usage_cron()
    {
    global 
$update_disk_usage_batch_size;

    
$lastrun get_sysvar('last_update_disk_usage_cron''1970-01-01');
    
# Don't run if already run in last 24 hours.
    
if (time()-strtotime($lastrun) < 24*60*60)
        {
        echo 
" - Skipping update_disk_usage_cron  - last run: " $lastrun "<br/>\n";
        return 
false;
        }
    if (
is_process_lock("disk_usage_cron"))
        {
        echo 
" - disk_usage_cron process lock is in place. Skipping.\n";
        return;
        }
    
set_process_lock("disk_usage_cron");

    
$resources=ps_array(
        
"SELECT ref value
            FROM resource
        WHERE ref>0
            AND disk_usage_last_updated IS null
                OR datediff(now(),disk_usage_last_updated)>30
        ORDER BY disk_usage_last_updated ASC
        LIMIT " 
. (int) $update_disk_usage_batch_size,
        []);
    foreach (
$resources as $resource)
        {
        
update_disk_usage($resource);
        }

    
clear_query_cache("stats");
    
set_sysvar("last_update_disk_usage_cron",date("Y-m-d H:i:s"));
    
clear_process_lock("disk_usage_cron");
    }

This article was last updated 17th May 2024 21:35 Europe/London time based on the source file dated 17th May 2024 18:10 Europe/London time.