PHPackages                             dades/scheduledtask - 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. [CLI &amp; Console](/categories/cli)
4. /
5. dades/scheduledtask

ActiveLibrary[CLI &amp; Console](/categories/cli)

dades/scheduledtask
===================

The Symfony Bundle to schedule tasks

v1.0.5(6y ago)092MITPHPPHP ^7.0

Since Apr 22Pushed 6y agoCompare

[ Source](https://github.com/DamienDeSousa/scheduledTaskBundle)[ Packagist](https://packagist.org/packages/dades/scheduledtask)[ RSS](/packages/dades-scheduledtask/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (5)Versions (8)Used By (0)

Dades\\ScheduledTaskBundle
==========================

[](#dadesscheduledtaskbundle)

A Symfony Bundle that schedule tasks and commands on Windows and Linux.
It uses the cron system from Linux on both operating systems.

Installation
------------

[](#installation)

1. Run the following command to add the bundle to your project as a composer dependency:
    `composer require dades/scheduledtask`
2. Add the bundle to your application kernel:

```
// app/AppKernel.php
public function registerBundles()
{
    // ...
    $bundle = array(
        // ...
        new Dades\ScheduledTaskBundle\DadesScheduledTaskBundle(),
    );
    // ...

    return $bundles;
}
```

3. If you didn't create your database before, run `php bin/console doctrine:database:create`
4. Then you have to create the table that will store your scheduled tasks:
    `php bin/console doctrine:schema:update --force`

### Windows OS

[](#windows-os)

5. You have to tell to your system to check every minute if a task should be run. To do that, run the following command on your cmd:
    `schtasks /CREATE /TN "uniqueName" /TR "php D:\path\to\your\project\bin\console cron:run" /SC minute`

Make sure that schtasks is globally install on your system.

### Linux OS

[](#linux-os)

5. You have to tell to your system to check every minute if a task should be run. To do that, you have to add a cronjob in your crontab:
    1. run `crontab -e` to edit your crontab
    2. add `* * * * * php /path/to/your/project/bin/console cron:run >> ~/tmp 2>&1` in the file

How it works
------------

[](#how-it-works)

Now you're ready to create all the scheduled tasks you want. You just need to handle these 2 classes:
Dades\\ScheduledTaskBundle\\Entity\\ScheduledTask
Dades\\ScheduledTaskBundle\\Service\\ScheduledTaskService

Inject the service that handles ScheduledTask class:

```
use Dades\ScheduledTaskBundle\Service\ScheduledTaskService;

public function indexAction(Request $request, ScheduledTaskService $scheduled)
{
    //code
}
```

Note that this is a Service, so you can inject it anywhere you want.

### Create a scheduled task

[](#create-a-scheduled-task)

Once your Service is injected, you can do the following thing:

```
public function indexAction(Request $request, ScheduledTaskService $scheduledTaskService)
{
    $task = $scheduledTaskService->create();
    $task->setCommand("php --version")->setCronExpresion("* * * * *");
    $scheduledTaskService->save($task);

    return new Response("it works");
}
```

In this example, the "php --version" command will be run every minute.

### Get one or more scheduled tasks

[](#get-one-or-more-scheduled-tasks)

You can get a task by its id or get all tasks in an array. Example:

```
public function indexAction(Request $request, ScheduledTaskService $scheduledTaskService)
{
    //get the task with id 1
    $task = $scheduledTaskService->getScheduledTask(1);
    //get all tasks
    $tasks = $scheduledTaskService->getScheduledTasks();

    //...
}
```

### Update a scheduled task

[](#update-a-scheduled-task)

To update a task, just set the value that you want to change and call the ScheduledTaskService:

```
public function indexAction(Request $request, ScheduledTaskService $scheduledTaskService)
{
    //get the task with id 1
    $task = $scheduledTaskService->getScheduledTask(1);
    $task->setCommand("crontab -l")->setCronExpresion("0 5 * * *");
    $scheduledTaskService->update($task);

    //...
}
```

### Delete a task

[](#delete-a-task)

You have to get the task that you want to remove and call the delete method:

```
public function indexAction(Request $request, ScheduledTaskService $scheduledTaskService)
{
    //get the task with id 1
    $task = $scheduledTaskService->getScheduledTask(1);
    $scheduledTaskService->delete($task);

    //...
}
```

### Where the magic happens

[](#where-the-magic-happens)

Now you know how to install, setup and handle scheduled tasks, but you don't know yet where they are executed.
Just have a look in the Dades\\ScheduledTaskBundle\\Command\\RunCronCommand class.

```
if ($this->scheduledTaskService->isDue($task)) {
    exec($task->getCommand(), $stderr, $status);
```

These 2 lines to the trick.
The first line check if the task $task must be run now.
The second line execute the command.

More informations
-----------------

[](#more-informations)

The stdout and stderr streams are logged in the var/logs/dades\_scheduled\_task\_bundle.log.
Thanks to this file, you have a trace of all your task executions.
If the file doesn't exist, don't worry, it will be automatically created.

This bundle use the dragonmantank/cron-expression library.
This lib read the cron expression of each task to determine if this task should be run now.
I invite you to read more about this [here](https://packagist.org/packages/dragonmantank/cron-expression).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~51 days

Recently: every ~63 days

Total

7

Last Release

2318d ago

Major Versions

1.x-dev → 2.x-dev2020-02-24

PHP version history (2 changes)v1.0.1PHP ^7.0

1.x-devPHP &gt;=7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1574565?v=4)[dades](/maintainers/dades)[@dades](https://github.com/dades)

---

Top Contributors

[![DamienDeSousa](https://avatars.githubusercontent.com/u/22929605?v=4)](https://github.com/DamienDeSousa "DamienDeSousa (18 commits)")

---

Tags

symfonycronschedulelinuxwindowsmultiplatforme

### Embed Badge

![Health badge](/badges/dades-scheduledtask/health.svg)

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

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1175.2k](/packages/rcsofttech-audit-trail-bundle)[shapecode/cron-bundle

This bundle provides scheduled execution of Symfony commands

58517.1k2](/packages/shapecode-cron-bundle)[forumify/forumify-platform

122.0k12](/packages/forumify-forumify-platform)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

939.0k](/packages/ahmed-bhs-doctrine-doctor)

PHPackages © 2026

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