Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Crontab Bundle Laravel Package

ecentria/crontab-bundle

View on GitHub
Deep Wiki
Context7

Ecentria Crontab Bundle

Crontab Functionality of scheduling cron jobs. The software utility cron is a time-based job scheduler in Unix-like computer operating systems. People who set up and maintain software environments use cron to schedule jobs to run periodically at fixed times, dates, or intervals. This bundle provides a simple possibility to control crontab on application level. Provides a possibility to auto-setup cron jobs required for project based on configuration file.

Table of Contents

  1. Installation
  2. Configuration
  3. Usage
  4. License
  5. Important Notice

Installation

console

$ composer require ecentria/crontab-bundle

php

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Ecentria\Bundle\CrontabBundle\EcentriaCrontabBundle()
        );
        
        // ...
    }
}

Configuration

Bundle supports defining configuration by using regular expressions. Sequence of consumers collecting:

  • Exact match will go first, if match is found collecting is finished.
  • Searching for first match by regular expression

config/packages/ecentria_crontab.yml

ecentria_crontab:
    path: 'home/sites/shared/crontab' 
    user: 'project_specific_user'
    mailto: 'your.email@address.com'
    jobs:
        backend.example.com: # It must contain valid hostname, see Services/StaticJobProvider::provide()
            -
                description: 'Backend'
                frequency:   '* * * * *'
                command:     'php /home/sites/current/bin/console backend'
                parameters:  '--env=prod --no-debug'
        node-\d+.example.com:
            -
                description: 'Node job 1'
                frequency:   '* * * * *'
                command:     'php /home/sites/current/bin/console node'
                parameters:  '--execute=foo --env=prod --no-debug'
            -
                description: 'Node job 2'
                frequency:   '* * * * *'
                command:     'php /home/sites/current/bin/console node'
                parameters:  '--execute=bar --env=prod --no-debug'

Usage

Setup your crontab after deployment

php bin/console ecentria:crontab:install --env=prod --no-debug

After command finished it's job you can check crontab with:

crontab -l

And if everything is correct you should see

node-1.example.com

# This file has been generated dynamically
# All manual changes will be erased soon

MAILTO="your.email@address.com"

# Node job 1
* * * * * php /home/sites/current/bin/console node --execute=foo --env=prod --no-debug

# Node job 2
* * * * * php /home/sites/current/bin/console node --execute=bar --env=prod --no-debug

License

The MIT License

Copyright (c) 1999-2018 Ecentria Group http://www.ecentria.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Important Notice

Ecentria Crontab Bundle schedules jobs using Crontab. A best practice for two or more applications that run on the same node is to assign a different user per application.

The best practice mentioned above prevents different applications overwriting each other's configurations. One user has only one cron table file, normally stored on /var/spool/cron/

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky