PHP code example of tourze / workerman-core-dump-cleaner

1. Go to this page and download the library: Download tourze/workerman-core-dump-cleaner library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tourze / workerman-core-dump-cleaner example snippets




use Tourze\Workerman\CoreDumpCleaner\CoreDumpCleaner;

// Initialize with project directory and optional cron schedule
// Default schedule is every 30 seconds
new CoreDumpCleaner('/path/to/project', '*/30 * * * * *');



use Tourze\Workerman\CoreDumpCleaner\CoreDumpCleaner;

// Custom configuration
$cleaner = new CoreDumpCleaner(
    projectDir: '/path/to/project',
    rule: '0 */10 * * * *',           // Every 10 minutes
    maxCoreFiles: 50,                 // Monitor up to 50 core files
    registerCrontab: true             // Auto-register cron job
);

// For testing purposes (disable cron registration)
$cleaner = new CoreDumpCleaner(
    projectDir: '/path/to/project',
    registerCrontab: false
);

// Manual cleanup
$results = $cleaner->cleanFiles();