Download the PHP package silverstripe/crontask without Composer

On this page you can find all versions of the php package silverstripe/crontask. 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 crontask

Silverstripe CronTask

CI

Gives developers an ability to configure cron-like tasks through the code.

This module intentionally doesn't surface any of the configuration or logs to the CMS, being of an opinion these tasks belong with developers and sysadmins. If you want that, see the "CMS-driven scheduler" section below.

What problem does module solve?

Developers don't always have access to the server to configure cronjobs, and instead they have to rely on server administrators to do it for them. This can slow down development cycles, and can lead to misunderstandings and misconfigurations if cronjobs are set up by hand.

This module solves this by getting the sysadmin to set up a single generic cronjob on the server side, and delegate the actual job definition to the PHP code.

CMS-driven scheduler

If you are looking for CMS-controllable scheduler, please check out the queuedjobs module. Here are some examples of how to implement recurring jobs with that module:

Installing

Add the following to your project's composer.json:

Run composer update (this will also install needed 3rd party libs in ./vendor)

Usage

Implement the CronTask interface on a new or already existing class:

Run vendor/bin/sake dev/build flush=1 to make Silverstripe aware of the new module.

Then execute the crontask controller, it's preferable you do this via the CLI since that is how the server will execute it.

Server configuration

Linux and Unix servers often comes installed with a cron daemon that are running commands according to a schedule. How to configure these can vary a lot but the most common way is by adding a file to the /etc/cron.d/ directory.

First find the correct command to execute, for example:

Then find out which user the webserver is running on, for example www-data.

Then create / edit the cron definition:

The content of that file should be:

This will run every minute as the www-data user and check if there are any outstanding tasks that needs to be executed.

By default this will output information on which cron tasks are being executed - if you are monitoring cron output for errors you can suppress this output by adding quiet=1 - for example

Warning: Observe that the crontask module doesn't do any checking. If you define a task to run every 5 mins it will run every 5 minutes whether it completed or not (as a normal cron would). If the run time of an 'every-5-minutes' task started at 17:10 is more than five minutes, it starts another process at 17:15 which may interfere with the still running process. You can either make the task run less often or use something like queuedjobs, which allows a job to re-schedule itself at a certain period after finishing (see 'CMS-driven scheduler' above).

For more information on how to debug and troubleshoot cronjobs, see http://serverfault.com/a/449652.

The getSchedule() method

The crontask controller expects that the getSchedule returns a string as a cron expression.

Some examples:

Example:

If getSchedule() returns false, '', or null, then it is assumed that this task is disabled. This can be useful if getSchedule() returns the value of a config variable.

The process() method

The process method will be executed only when it's time for a task to run (according to the getSchedule method). What you do in here is up to you. You can either do work in here or for example execute BuildTasks run() methods.

CRON Expressions

A CRON expression is a string representing the schedule for a particular command to execute. The parts of a CRON schedule are as follows:

For more information about what cron expression is allowed, see the Cron-Expression post from the creator of the 3rd party library.

Contribute

Do you want to contribute? Great, please see the CONTRIBUTING.md guide.

License

This module is released under the BSD 3-Clause License, see LICENSE.

Code of conduct

When having discussions about this module in issues or pull request please adhere to the Silverstripe Community Code of Conduct.

Thanks

Thanks to Michael Dowling for doing the actual job of parsing cron expressions.

This module is just a thin wrapper around his code.


All versions of crontask with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
dragonmantank/cron-expression Version ^3
silverstripe/framework Version ^5
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 silverstripe/crontask contains the following files

Loading the files please wait ....