PHPackages                             egersdorfer/crontab - 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. egersdorfer/crontab

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

egersdorfer/crontab
===================

PHP Cronjob manager

1611312PHP

Since Dec 22Pushed 11y ago2 watchersCompare

[ Source](https://github.com/codeChap/crontab)[ Packagist](https://packagist.org/packages/egersdorfer/crontab)[ RSS](/packages/egersdorfer-crontab/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Crontab
=======

[](#crontab)

Simple, independant and local PHP Crontab package

The package helps you manage your local cron jobs using PHP. You can list, append and remove your jobs and set your log file.

Requirements
------------

[](#requirements)

Should work on monst Linux flavoured systems.

Usage Example
-------------

[](#usage-example)

Use [composer](http://getcomposer.org) to install it or simply include the file somewhere: require("crontab/src/Crontab/Crontab.php");

Append two new jobs and set them to run every minute:

```
    $cron = new \Crontab\Crontab();
    $cron->setMinute("*");
    $cron->setHour("*");
    $cron->setDayOfMonth("*");
    $cron->setMonth("*");
    $cron->setDayOfWeek("*");
    $cron->append(array(
                "date",
                "ls -all"
            )
        );
    $commandsList = $cron->execute();
```

Methods
-------

[](#methods)

#### append($command)

[](#appendcommand)

Appends a new job to the current cronjob list

Parameters: $command : String or array of commands.

```
  $cron = new \Crontab\Crontab();
  $cron->setMinute("*");
  $cron->setHour("*");
  $cron->setDayOfMonth("*");
  $cron->setMonth("*");
  $cron->setDayOfWeek("*");
  $cron->append("date");
  $cron->execute();
```

#### remove($command)

[](#removecommand)

Removes a job from the current cronjob list. You must recreate the exact job to remove it.

Parameters: $command : String or array of commands

```
  $cron = new \Crontab\Crontab();
  $cron->setMinute("*");
  $cron->setHour("*");
  $cron->setDayOfMonth("*");
  $cron->setMonth("*");
  $cron->setDayOfWeek("*");
  $cron->remove("date");
  $cron->execute();
```

#### getJobs()

[](#getjobs)

Return a current list of jobs with there hashed keys

```
  $cron = new \Crontab\Crontab();
  $cron->setMinute("*");
  $cron->setHour("*");
  $cron->setDayOfMonth("*");
  $cron->setMonth("*");
  $cron->setDayOfWeek("*");
  $cron->remove("date");
  $cron->execute();
```

#### removeByKey($key)

[](#removebykeykey)

Removes a job from the current cronjob list by a hash key. Found by running execute() or getJobs()

Parameters: $key : String or array of keys

```
  $cron = new \Crontab\Crontab();
  $cron->removeByKey("1231231231231231231");
  $cron->execute();
```

#### execute()

[](#execute)

Applies and writes the new cronjob list.

```
    $cron->setMinute("*");
    $cron->setHour("*");
    $cron->setDayOfMonth("*");
    $cron->setMonth("*");
    $cron->setDayOfWeek("*");
    $cron->append("date");
    $cron->execute();
```

#### clear()

[](#clear)

Simply removes all running jobs by executing crontab -r

```
    $cron = new \Crontab\Crontab();
    $cron->clear();

```

Settings
--------

[](#settings)

Settings can also be applied to the constuct method like so:

```
    $conf = array(
		'minute' => '*',
		'hour' => '*',
		'dayOfMonth' => '*',
		'month' => '*',
		'dayOfWeek' => '*',
		'logFile' => 'log.txt',
		'tmpFile' => 'jobs.txt'
	);

    $cron = new \Crontab\Crontab($conf);
```

### Setting functions (Defaults are all "\*" here)

[](#setting-functions-defaults-are-all--here)

```
setMinute($m) : Sets the minute.
setHour($h) : Sets the hour.
setDayOfMonth($dom) : Sets the date of the month.
setMonth($m) : Sets the month.
setDayOfWeek($dow) : Sets the day of the week.

```

### Log and tempory file settings

[](#log-and-tempory-file-settings)

```
setLogFile($v) : Sets the log file and will attempt to create it. The default is /dev/null ie: nothing logged
setTmpFile($v) : Sets the tempory file used by crontab to read from, this file is automatically removed. The default is "jobs.txt"

```

Helpers
-------

[](#helpers)

Execute this job in 5 minutes from now.

```
    $cron = new \Crontab\Crontab();
    $cron->minuteFromNow(5);
    $cron->execute();
```

Help understanding cronjobs
---------------------------

[](#help-understanding-cronjobs)

A Google search should provied plenty of links but check out: [Kevin van Zonneveld's blog](http://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/) if you need help.

Todo
----

[](#todo)

- Email instead of log or both.
- Build in more heler functions.
- Unit tests

Disclaimer
----------

[](#disclaimer)

Use this library at your own risk.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb9295442ae3080252d831794578a67b53968136834c0ebb1878d4f495a1f79a?d=identicon)[CodeChap](/maintainers/CodeChap)

---

Top Contributors

[![devsdmf](https://avatars.githubusercontent.com/u/1649565?v=4)](https://github.com/devsdmf "devsdmf (1 commits)")

### Embed Badge

![Health badge](/badges/egersdorfer-crontab/health.svg)

```
[![Health](https://phpackages.com/badges/egersdorfer-crontab/health.svg)](https://phpackages.com/packages/egersdorfer-crontab)
```

###  Alternatives

[zservices/query

Pacote para consultas em serviços do governo.

131.1k](/packages/zservices-query)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
