DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:cronojob

cronojob Plugin

Compatible with DokuWiki

Lemming

plugin A plugin for schedule jobs

Last updated on
2010-04-22
Provides
Action

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with jobs, maintenance, scheduling

Description

The cronojob plugin allow to schedule jobs to run to a specific time, using a modified version of pseudo-cron PHP library.

Usually regular tasks like backup up or site maintenaince are run using cron jobs. With cron jobs, you can exactly plan when a certain command is to be executed. But most homepage owners can't create cron jobs on their web server – providers demand some extra money for that.

The only thing that's certain to happen quite regularly on a web page are page requests. This is where cronojob comes into play: with every page request it checks if any cron jobs should have been run since the previous request. If there are, they are run and logged.

Cronojob uses a syntax very much like the Unix cron's one. For an overview of the syntax used, see the cronotab syntax. The syntax used by this plugin is different from the one described on that page in the following points:

  • here is no user column
  • the executed command has to be an include()able file (which may contain further PHP code)

Usage

All job definitions are made by the admin's side configuration. Here is an example of a valid crono table configuration:

#comments start with '#'
#mi  h    d    m    dow      job                       comment
0    5    *    *    Sun      dump.php     # make db dump every sunday at 5 am
40   5    2    *    *        sendlog.php  # send last month's web server logs
*/15 8-19 *    *    Mon-Fri  refr_ext.php # refresh external news sources

The last line will call refr_ext.php every 15 minutes between 8 AM and 7 PM on Monday to Friday.

Write a PHP script that does the job you want to be run regularly. Put this file into lib/plugins/cronojob/jobs folder. Set up your crono table configuration with your script. Wait for the next scheduled run :)

You can log messages from your job script to Cronojob's log file by calling logMessage(“log a message”).

Version history

  • 2010-04-22 (current)
    • runs any PHP script periodical or time-controlled script execution
    • logs all executed jobs
    • run from an IMG tag in an HTML page
    • follows Unix cron syntax for crontabs
    • can sends an email with the results
    • the number of jobs run during one call of cronojob can now be limited.
    • sample script “clearcache”, that clear older cache and lock files

Discussion

There's always room for improvement. If you're able to add any contributions to make cronojob better, please let me know or discuss your thoughts right here (please use ===== Level 2 Headlines ===== to open a new “thread”/issue and ---- (four dashes, horizontal rule) to structure it when needed).

Request

Could you please provide PHP versions of the scripts from the Maintenance page to use with the plugin?

Is the plugin compatible with Rincewind?

plugin/cronojob.txt · Last modified: 2023-12-21 16:36 by Aleksandr

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki