Giter Site home page Giter Site logo

phpgt / cron Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 3.0 190 KB

Run scripts or static functions at regular intervals.

Home Page: https://www.php.gt/cron

License: MIT License

PHP 100.00%
background-jobs cron cron-runner cronjob cronjob-scheduler crontab regular-intervals

cron's People

Contributors

g105b avatar peter279k avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

cron's Issues

Post-cron command

Allow a configuration option to set a particular command to run after each cron task has completed.

This will be totally optional, but will allow for monitoring of cron's health without having to implement any additional services.

Improve CLI

  1. Standardise namespace
  2. Use proper stream
  3. Type improvements

Sub-minute syntax

This is non-standard, but it would be nice to be able to schedule a script for every 10 seconds. At the moment, * * * * * is equal to once per minute, which is currently the most frequent cron setting.

Setting */10 * * * * will trigger every 10 minutes.

My proposed syntax for every 10 seconds:

*:10 * * * *

The colon is obviously different than the slash, and is already used in time formats, so it shouldn't be too difficult to understand what this does without reading the docs.

Explain crons in crontab

An --explain flag would be brilliant. It would list out the cron jobs you have in the crontab file and explain when they will run.

Example output:

0 0 * * FRI /backup		At 12:00 AM, only on Friday
0 * * * * /clean-cache		Every hour
05 01 * * SUN#1			At 01:05 AM, on the first Sunday of the month

Test "validate" cli command

The validate command has been created to output OK on no errors and pass the original parse exception on error. There are currently no tests in place for this.

@background and @start

Linux crontab supports replacing the date/time columns with @reboot to indicate that the script should be run once on reboot.

As a new feature, @background can be used to indicate that the script should be run forever in the background (waiting for the process to finish before starting again).

@start can be used to indicate that the script should be run once at the start of the server starting.

Ensure tasks are running in their own process

This may already be the case, but it's worth double checking and putting in the documentation.

The way the Linux cron system works is that all tasks are run concurrently. This needs to be the case for this project too.

Imagine there are some background scripts that take 20 seconds to run. Put them in on the crontab to run every minute, and they should be completed concurrently within their 20 second execution time... however if they are not run concurrently, more than three scripts will overlap into the next minute, and things will catch fire rather quickly.

Automatically create and install .service file

A bin file in the vendor/bin directory should be created that allows creating and installing the relevant .service file for the systemd process to call the correct cron processing script.

Specify what jobs have just run

Just ran 1 job, next job at: 21:16:00.

It would be nicer if it said "Just ran 1 job (script/cache/refresh)"

The "next job at" can be on its own line.

Run all cron tasks at start

Pass a flag such as --all to run all of the cron tasks instantly when cron is called. Useful for local development.

Cron top-level directory with named scripts

It would be nice to be able to treat cron scripts in the same way as we do Page Logic files, almost as if (or maybe completely as if) the scripts are being routed.

Inside the crontab file, we could have something like the following:

0 5 * * * /cache?type=db&mode=daily

This would be triggered at 0500 every day, and it makes sense to store this script in the cron/cache.php file.

Inside the file, it can behave completely like any other go function:

<?php
use Gt\Input\Input;

function go(Input $input, Database $db):void {
  if($input->getString("type") === "db") {
    $db->clean(); // or whatever...
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.