Download the PHP package tiben/crontab-manager without Composer

On this page you can find all versions of the php package tiben/crontab-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package crontab-manager

CrontabManager

PHP library to manage programmatically GNU/Linux cron jobs.

It enables you to :

Requirements

Installation

The library can be installed using Composer.

composer require tiben/crontab-manager ~1.0

Usage

The library is composed of three classes:

Instantiate the repository

In order to work, the CrontabRepository needs an instance of CrontabAdapter.

Create new Job and persist it into the crontab

Suppose you want to create a new job which consists of launching the command "df >> /tmp/df.log" every day at 23:30. You can do it in two ways.

You can now add your new cronjob in the crontab repository and persist all changes to the crontab.

Find a specific cron job from the crontab repository and update it

Suppose we want to modify the hour of an already existing cronjob. Finding existings jobs is done using some regular expressions. The regex is applied to the entire crontab line.

Remove a cron job from the crontab

You can remove a job like this :

Note: Since cron jobs are internally matched by reference, they must be previously obtained from the repository or previously added.

Work with the crontab of another user than runtime user

This feature allows you to manage the crontab of another user than the user who launched the runtime. This can be useful when the runtime user is www-data but the owner of the crontab you want to edit is your own linux user account.

To do this, simply pass the username of the crontab owner as parameter of the CrontabAdapter constructor. Suppose you are www-data and you want to edit the crontab of user bobby:

Using this way you will propably run into user rights issues. This can be handled by editing your sudoers file using 'visudo'.\ If you want to allow user www-data to edit the crontab of user bobby, add this line:

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

which tells sudo not to ask for password when user www-data calls crontab as user bobby using sudo

Now, you can access to the crontab of user bobby like this :

Note the second parameter true of the CrontabAdapter constructor call. This boolean tells the CrontabAdapter to use sudo internally when calling crontab.

Enable or disable a cron job

You can enable or disable your cron jobs by using the setEnabled() method of a CronJob object accordingly :

This will prepend your cron job with a # in your crontab when persisting it.

Write your own adapter

Additionally, if you cannot read another user's crontabs or if you are on a distributed architecture where crons are not run on the machine executing the jobs, you can create any other Adapter for your architecture by implementing the CrontabAdapterInterface.

You can then instantiate the CrontabRepository with your adapter.

Unit tests

Tests have been written using PHPUnit and require version 5.3+. To execute tests:

$ phpunit <crontab-library-path>/tests

If you installed the library using Composer and installed dev-dependencies you can execute them using included PHPUnit as dependency:

$ ./vendor/bin/phpunit <crontab-library-path>/tests

Contributions

... are welcome :)


All versions of crontab-manager with dependencies

PHP Build Version
Package Version
Requires php Version >= 5.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tiben/crontab-manager contains the following files

Loading the files please wait ....