PHPackages                             battis/autocrontabjob - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. battis/autocrontabjob

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

battis/autocrontabjob
=====================

An object-oriented approach to scheduling regular cron jobs automatically

v1.0.1(9y ago)067LGPL-3.0PHP

Since Aug 11Pushed 4y ago3 watchersCompare

[ Source](https://github.com/battis/autocrontabjob)[ Packagist](https://packagist.org/packages/battis/autocrontabjob)[ RSS](/packages/battis-autocrontabjob/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

AutoCrontabJob
==============

[](#autocrontabjob)

[![Latest Version](https://camo.githubusercontent.com/54c94238c6452ef8439d9a9e0197dbef71b0cb9fde4a198e17779974ea74dfe6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6261747469732f6175746f63726f6e7461626a6f622e737667)](https://packagist.org/packages/battis/autocrontabjob)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8779dc7d02dc06dbf3d033d342a1e87c2cebc1806ac24f02476498ee6baa1daa/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6261747469732f6175746f63726f6e7461626a6f622f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/battis/autocrontabjob/?branch=master)

An object-oriented approach to scheduling regular cron jobs automatically

### Install

[](#install)

Include in your `composer.json`:

```
"require": {
  "battis/autocrontabjob": "~1.0"
}
```

### Use

[](#use)

This object requires a bit of prior preparation before use:

1. Extend the abstract `Battis\AutoCrontabJob` class and implement the abstract `scheduledJob()` method.
2. Create a script that will be run regularly as a Cron job, that instantiates your class and calls its `scheduledJob()` method.

*Gotcha warning:* Remember that, when a script is run by cron, it is *not* run by Apache, so it will not generate output to the Apache log files. Handily, there is a log built-in that you can use (see below). By default, the log will be generated in the same directory as the script and be similarly named (`.log` instead of `.php`).

A sample script file (which is an all-in-one, also extending the abstract class), called `MyJob.php`:

```
