# Install Cronjobs on 5.2 programmatically

**URL:** <https://forum.shopware.com/t/install-cronjobs-on-5-2-programmatically/41096>\
**Category:** Programmierung\
**Created:** [4. November 2016 um 16:57 UTC](https://forum.shopware.com/t/install-cronjobs-on-5-2-programmatically/41096 "2016-11-04T16:57:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cboita](https://avatars.discourse-cdn.com/v4/letter/c/eb9ed0/32.png) [@cboita](https://forum.shopware.com/u/cboita)\
**Post date:** [4. November 2016 um 16:57 UTC](https://forum.shopware.com/t/install-cronjobs-on-5-2-programmatically/41096/1 "2016-11-04T16:57:59Z")

</div>

Hi guys

I can’t find documentation regarding how to install cronjobs using the new 5.2 Plugin System. Before, we had on Bootstrap the&nbsp;createCronJob(…) method available, but this is not available on \Shopware\Components\Plugin. What is the best way to do that using the new 5.2 PSystem?

Thanks.

&nbsp;

Best

---

<div class="post-metadata">

**Author:** ![hhmarco](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@hhmarco](https://forum.shopware.com/u/hhmarco)\
**Post date:** [5. November 2016 um 11:51 UTC](https://forum.shopware.com/t/install-cronjobs-on-5-2-programmatically/41096/2 "2016-11-05T11:51:29Z")

</div>

```
 In Your Plugin Class : 

$this->container->get('dbal_connection')->insert(
    's_crontab',
    [
        'name' => 'XXXX',
        'action' => 'Shopware_CronJob_XXXXXXXXXX', 
        'next' => new \DateTime(),
        'start' => null,
        '`interval`' => 60 * 5,
        'active' => true,
        'end' => new \DateTime(),
        'pluginID' => $context->getPlugin()->getId(),
    ],
    [
        'next' => 'datetime',
        'end' => 'datetime',
    ]
);

```

In your cronjob class

```
/**
* @return array
*/
public static function getSubscribedEvents()
{
    return [
        'Shopware_CronJob_XXXXXXXXXX' => 'execute'
    ];
}

```

&nbsp;
