Giter VIP home page Giter VIP logo

cronbundle's Introduction

CronBundle

This bundle provides cron management utilities for your Symfony Project

Installation

Add greg-doak/cron-bundle to your composer.json

$ composer require greg-doak/cron-bundle

Register the bundle in config/bundles.php

return [
    // ...
    GregDoak\CronBundle\GregDoakCronBundle::class => ['all' => true],
];

Create the database tables

$ php bin/console doctrine:migrations:diff
$ php bin/console doctrine:migrations:migrate

Or

$ php bin/console doctrine:schema:update --force

Create your first task

$ php bin/console cron:create

Configuration

Add the scheduler to your cron

*/5 * * * * php /root/to/your/application/bin/console cron:run:scheduled

Or alternatively to run the scheduler on page request Configure services.yaml

parameters:
    // ...
    gregdoak.cron.run_on_request: true

This can have performance issues so is recommended to run on Development environments only

Usage

Run a single task, you will be prompted for which task to run

$ php bin/console cron:run:single

Kill a running task, you will be prompted for the running task

$ php bin/console cron:kill

Update a task

$ php bin/console cron:update

Notes

There are 3 database tables created:

cron_jobs - A record is created whenever the scheduler or single task is run and ensures tasks cannot be ran simultaneously. It also records a start and end time to measure performance of the entire job

cron_job_tasks - Each record consists of a single task, running tasks will be reserved by recording a cron_job_id

cron_job_logs - A log is created for each task to record the output, exit code, start and end times

cronbundle's People

Watchers

 avatar  avatar

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.