2017 © Pedro Peláez
 

library cron

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).

image

qi-interactive/cron

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).

  • Saturday, July 18, 2015
  • by qiinteractive
  • Repository
  • 1 Watchers
  • 0 Stars
  • 123 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 78 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHP Crontab Manager

Last build status: Build Status, (*1)

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)., (*2)

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.:, (*3)

%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., (*4)

Usage

Here is a simple example of use. Adding a simple task to crontab:, (*5)

<?php
use qi\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:, (*6)

<?php
use qi\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.:, (*7)

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

The Versions

18/07 2015

dev-master

9999999-dev

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).

  Sources   Download

MIT

cron