Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 6326 to 6361

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 4th December 2024 08:35 Europe/London time based on the source file dated 28th November 2024 12:10 Europe/London time.