mybuilder / Cronos
Licence: mit
A PHP component for updating crontab
Stars: ✭ 145
Labels
Projects that are alternatives of or similar to Cronos
Ddns Route53
Dynamic DNS for Amazon Route 53 on a time-based schedule
Stars: ✭ 98 (-32.41%)
Mutual labels: cron
Cronscheduler.aspnetcore
Cron Scheduler for AspNetCore 2.x/3.x or DotNetCore 2.x/3.x Self-hosted
Stars: ✭ 100 (-31.03%)
Mutual labels: cron
Simple scheduler
An enhancement for Heroku Scheduler + Sidekiq for scheduling jobs at specific times.
Stars: ✭ 127 (-12.41%)
Mutual labels: cron
Wp Crontrol
WP Crontrol lets you view and control what's happening in the WP-Cron system.
Stars: ✭ 97 (-33.1%)
Mutual labels: cron
Go Quartz
Simple, zero-dependency scheduling library for Go
Stars: ✭ 118 (-18.62%)
Mutual labels: cron
Metronome
Metronome is a distributed and fault-tolerant event scheduler
Stars: ✭ 131 (-9.66%)
Mutual labels: cron
Crontabmanager
PHP library for GNU/Linux cron jobs management.
Stars: ✭ 113 (-22.07%)
Mutual labels: cron
Serverpilot Letsencrypt
Automate the installation of Let's Encrypt SSL on the free plan of ServerPilot
Stars: ✭ 129 (-11.03%)
Mutual labels: cron
Dropwizard Jobs
Scheduling / Quartz integration for Dropwizard
Stars: ✭ 132 (-8.97%)
Mutual labels: cron
Dottask
Simple and easy go task framework, support loop & cron & queue
Stars: ✭ 124 (-14.48%)
Mutual labels: cron
Cronos
Easily configure cron through PHP.
If you use Symfony 3/4/5, you could use our cool bundle in order to configure your app jobs through fancy annotations!
Setup and Configuration
Require the library via composer:
composer require mybuilder/cronos
Usage
Build Cron
<?php
require 'vendor/autoload.php';
$cron = new MyBuilder\Cronos\Formatter\Cron;
$cron
->header()
->setPath('path')
->setHome('home')
->setMailto('[email protected]')
->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
[email protected]
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
Updating Cron
<?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);
Troubleshooting
- The current user must have a existing crontab file to use the updater, use
crontab -e
to create one. - When a cron line is executed it is executed with the user that owns the crontab, but it will not execute any of the users default shell files so all paths etc need to be specified in the command called from the cron line.
- Your crontab will not be executed if you do not have usable shell in
/etc/passwd
- If your jobs don't seem to be running, check the cron daemon is running, also check your username is in
/etc/cron.allow
and not in/etc/cron.deny
. - Environmental substitutions do not work, you cannot use things like
$PATH
,$HOME
, or~/sbin
. - You cannot use
%
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.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].