Git Product home page Git Product logo

php-crontab-manager's Introduction

PHP Crontab Manager

Last build status: Build Status

Manages linux crontab file by adding and deleting the appropriate entries. It is able to track the source file so that after the changes to this file, he will be able to enter and update the user's crontab file in safe way (doesn't remove entries added by user using crontab -e).

Installation

  • copy files to your project
  • include files from src directory or use some autoloader
  • use it as described below

Requirements

If you are willing to use this tool as other user be sure enable appropriate entry into end of sudoers file (visudo) for ex.:

%developers ALL=(www-data)NOPASSWD:/usr/bin/crontab

Above means that users in a group developers can run program crontab as user www-data without need to enter the password.

Usage

Here is a simple example of use. Adding a simple task to crontab:

<?php
use php\manager\crontab\CrontabManager;

$crontab = new CrontabManager();
$job = $crontab->newJob();
$job->on('* * * * *');
$job->onMinute('20-30')->doJob("echo foo");
$crontab->add($job);
$job->onMinute('35-40')->doJob("echo bar");
$crontab->add($job);
$crontab->save();

A more complex example, but simpler to write. Adding and removing files to manage by the cron job. Files will be updated so as not to disrupt other tasks in the cron:

<?php
use php\manager\crontab\CrontabManager;

$crontab = new CrontabManager();
$crontab->enableOrUpdate('/tmp/my/crontab.txt');
$crontab->disable('/tmp/toremove.txt');
$crontab->save();

You can also use the built-in tools from the console: cronman located in the directory bin/ for ex.:

bin/cronman --enable /var/www/myproject/.cronfile --user www-data

php-crontab-manager's People

Contributors

cardil avatar ryanfaerman avatar

Watchers

James Cloos avatar jadeye 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.