mybuilder/cronos
Cronos is a Laravel-friendly task scheduling package for defining, running, and monitoring cron-style jobs from your app. Organize recurring tasks, trigger them on demand, and manage schedules with a clean API and sensible defaults.
Easily configure cron through PHP.
If you use Symfony 4/5/6, you could use our cool bundle in order to configure your app jobs through fancy annotations!
Require the library via composer:
composer require mybuilder/cronos
<?php
require 'vendor/autoload.php';
$cron = new MyBuilder\Cronos\Formatter\Cron;
$cron
->header()
->setPath('path')
->setHome('home')
->setMailto('test@example.com')
->setShell('shell')
->setContentType('text')
->setContentTransferEncoding('utf8')
->end()
->comment('Comment')
->job('/bin/bash command --env=dev')
->setMinute(1)
->setHour(2)
->setDayOfMonth(3)
->setMonth(4)
->setDayOfWeek(5)
->setStandardOutFile('log')
->appendStandardErrorToFile('error')
->end();
echo $cron->format();
That will print
MAILTO=test@example.com
HOME=home
SHELL=shell
LOGNAME=logName
CONTENT_TYPE=text
CONTENT_TRANSFER_ENCODING=utf8
#Comment
1 2 3 4 5 /bin/bash command --env=dev > log 2>> error
<?php
require 'vendor/autoload.php';
use MyBuilder\Cronos\Formatter\Cron;
use MyBuilder\Cronos\Updater\CronUpdater;
$cron = new Cron;
// $cron configuration...
$cronUpdater = CronUpdater::createDefault();
$cronUpdater->replaceWith($cron);
crontab -e to create one./etc/passwd/etc/cron.allow and not in /etc/cron.deny.$PATH, $HOME, or ~/sbin.% in the command, if you need to use it, escape the command in backticks.Created by MyBuilder - Check out our blog for more insight into this and other open-source projects we release.
How can I help you explore Laravel packages today?