PHP code example of mintware-de / native-cron

1. Go to this page and download the library: Download mintware-de/native-cron 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/ */

    

mintware-de / native-cron example snippets




declare(strict_types=1);

use MintwareDe\NativeCron\Content\BlankLine;
use MintwareDe\NativeCron\Content\CommentLine;
use MintwareDe\NativeCron\Content\CronJobLine;
use MintwareDe\NativeCron\CrontabManager;
use MintwareDe\NativeCron\Filesystem\DarwinCrontabFileLocator;
use MintwareDe\NativeCron\Filesystem\FileHandler;

('max');

// Display the current content of the crontab
echo $crontab->build();

$crontab
    // Add a new cronjob
    ->add(new CronJobLine('* * * * * echo "Hello World" >> /tmp/mylog'))
    // Remove all comments and blank lines
    ->removeWhere(fn ($line) => $line instanceof CommentLine || $line instanceof BlankLine);

// Display the new content of the crontab
echo $crontab->build();

// Write the crontab for the user max
// Keep in mind that reading or writing crontab files may