@prefix sioc: <http://rdfs.org/sioc/ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix content: <http://purl.org/rss/1.0/modules/content/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://lhero.org/portfolio/lh-disk-usage/>
  a sioc:Post ;
  dc:title "Data, cron and hooks" ;
  dcterms:identifier 151755 ;
  dc:modified "2026-10-19T12:25:23Z"^^xsd:dateTime ;
  dc:created "2026-10-19T12:01:44Z"^^xsd:dateTime ;
  sioc:link <https://lhero.org/portfolio/lh-disk-usage/data-cron-and-hooks/> ;
  sioc:has_creator <https://lhero.org/author/1/#account> ;
  sioc:has_container <https://lhero.org/#posts> ;
  content:encoded """<ul class="lh_portfolio-meta"><li><strong>Part of:</strong> <a href="https://lhero.org/portfolio/lh-disk-usage/">LH Disk Usage</a></li></ul>
<h2 class="wp-block-heading">Stored data</h2>



<ul class="wp-block-list">
<li><strong>Post meta</strong> on each attachment: <code>_lh_disk_usage_bytes</code> (original plus variants) and <code>_lh_disk_usage_original_bytes</code>, rewritten whenever the attachment&#8217;s metadata is saved. Both keys are filterable.</li>



<li><strong>Option</strong> <code>lh_disk_usage_backfill_done</code> on each site, set (to a GMT time) once every attachment has been measured.</li>



<li><strong>Network table</strong> <code>{base_prefix}lh_disk_usage_snapshots</code> on the main site: one row per install scan with its root, depth, driver, completeness, total and a JSON payload of the tree and large files. The newest 20 are kept. Its schema is tracked by the network option <code>lh_disk_usage_snapshots_schema_version</code>.</li>



<li><strong>Network options</strong> <code>lh_disk_usage_site_storage</code> (each site&#8217;s latest measurement) and <code>lh_disk_usage_measure_cursor</code> (where an unfinished pass resumes), and the network transient <code>lh_disk_usage_legacy_meta_count</code>.</li>



<li>Site totals are cached in the object cache group <code>lh_disk_usage</code> for an hour and cleared whenever an attachment is measured or deleted.</li>
</ul>



<h2 class="wp-block-heading">Cron</h2>



<ul class="wp-block-list">
<li><code>lh_disk_usage_backfill</code>: single events on each site, scheduled from <code>admin_init</code> until the backfill is done, measuring 100 unmeasured attachments every 30 seconds.</li>



<li><code>lh_disk_usage_measure_sites</code>: daily on the main site, measuring sites until the 20-second budget has passed between sites; an unfinished pass reschedules itself a minute later with the argument <code>continue</code>.</li>
</ul>



<h2 class="wp-block-heading">Filters</h2>



<ul class="wp-block-list">
<li><code>lh_disk_usage_init_plugin</code>: return false to stop the plugin loading.</li>



<li><code>lh_disk_usage_return_capability</code> (default <code>manage_options</code>) and <code>lh_disk_usage_return_network_capability</code> (default <code>install_plugins</code>).</li>



<li><code>lh_disk_usage_calculate</code>: the measurement of one attachment, with the attachment ID and metadata.</li>



<li><code>lh_disk_usage_return_total_meta_key</code>, <code>lh_disk_usage_return_original_meta_key</code>, <code>lh_disk_usage_return_backfill_batch_size</code> (100).</li>



<li><code>lh_disk_usage_use_shell</code> (true): return false to always use the PHP driver.</li>



<li><code>lh_disk_usage_return_shell_time_budget</code> (240 seconds per du or find command, always held 30 seconds under PHP&#8217;s <code>max_execution_time</code>) and <code>lh_disk_usage_return_time_budget</code> (20 seconds, for the PHP walk and between sites).</li>



<li><code>lh_disk_usage_return_max_depth</code> (4), <code>lh_disk_usage_return_max_children</code> (30 per directory), <code>lh_disk_usage_return_large_file_bytes</code> (10 MB), <code>lh_disk_usage_return_large_file_limit</code> (50).</li>



<li><code>lh_disk_usage_return_allowed_roots</code>: the directories a scan can start from, as key =&gt; path. Every path is still checked to be inside the install.</li>



<li><code>lh_disk_usage_return_snapshots_keep</code> (20) and <code>lh_disk_usage_return_legacy_meta_keys</code> (<code>SS88MLFS</code>, <code>SS88MLFSV</code>).</li>
</ul>
"""^^rdf:XMLLiteral ;
  sioc:content """Part of: LH Disk Usage
Stored data




Post meta on each attachment: _lh_disk_usage_bytes (original plus variants) and _lh_disk_usage_original_bytes, rewritten whenever the attachment&#8217;s metadata is saved. Both keys are filterable.



Option lh_disk_usage_backfill_done on each site, set (to a GMT time) once every attachment has been measured.



Network table {base_prefix}lh_disk_usage_snapshots on the main site: one row per install scan with its root, depth, driver, completeness, total and a JSON payload of the tree and large files. The newest 20 are kept. Its schema is tracked by the network option lh_disk_usage_snapshots_schema_version.



Network options lh_disk_usage_site_storage (each site&#8217;s latest measurement) and lh_disk_usage_measure_cursor (where an unfinished pass resumes), and the network transient lh_disk_usage_legacy_meta_count.



Site totals are cached in the object cache group lh_disk_usage for an hour and cleared whenever an attachment is measured or deleted.




Cron




lh_disk_usage_backfill: single events on each site, scheduled from admin_init until the backfill is done, measuring 100 unmeasured attachments every 30 seconds.



lh_disk_usage_measure_sites: daily on the main site, measuring sites until the 20-second budget has passed between sites; an unfinished pass reschedules itself a minute later with the argument continue.




Filters




lh_disk_usage_init_plugin: return false to stop the plugin loading.



lh_disk_usage_return_capability (default manage_options) and lh_disk_usage_return_network_capability (default install_plugins).



lh_disk_usage_calculate: the measurement of one attachment, with the attachment ID and metadata.



lh_disk_usage_return_total_meta_key, lh_disk_usage_return_original_meta_key, lh_disk_usage_return_backfill_batch_size (100).



lh_disk_usage_use_shell (true): return false to always use the PHP driver.



lh_disk_usage_return_shell_time_budget (240 seconds per du or find command, always held 30 seconds under PHP&#8217;s max_execution_time) and lh_disk_usage_return_time_budget (20 seconds, for the PHP walk and between sites).



lh_disk_usage_return_max_depth (4), lh_disk_usage_return_max_children (30 per directory), lh_disk_usage_return_large_file_bytes (10 MB), lh_disk_usage_return_large_file_limit (50).



lh_disk_usage_return_allowed_roots: the directories a scan can start from, as key =&gt; path. Every path is still checked to be inside the install.



lh_disk_usage_return_snapshots_keep (20) and lh_disk_usage_return_legacy_meta_keys (SS88MLFS, SS88MLFSV).

""" ;
  sioc:topic <https://lhero.org/?taxonomy=author&term=cap-1> .

<https://lhero.org/author/1/#account> rdfs:seeAlso <https://lhero.org/author/1/?feed=lhrdf&format=turtle> .
<https://lhero.org/?taxonomy=author&term=cap-1> rdfs:seeAlso <https://lhero.org/?taxonomy=author&term=cap-1&feed=lhrdf&format=turtle> .
