Skip to content

Crontab Jobs

Global crontab jobs list

Crontab jobs list

The crontab jobs page allows you to view all the crontab jobs in your project:

  • Module
  • Name
  • Instance (class and method)
  • Schedule (cron expression and human-readable format, i.e. * * * * * and Every minute)

Module crontab jobs list

In the module detail view, you can see the crontab jobs declared by this module.

Module crontab job creation

You can create a new command by clicking Generate > Crontab job button from the module detail view.

Crontab job create

The module crontab job creation wizard includes the following features:

  • Autocomplete the list of available crontab groups
  • Live display the human-readable format of the cron expression

The following files are created/updated in app/code/Vendor/Module when you create a new crontab job:

  • etc/crontab.xml: created if it does not exist, or updated with the new crontab job declaration
  • Cron/CronName.php: created with the new crontab job class

NOTE

The crontab job class name is inferred from the crontab job name you provide.

Example of a generated crontab job

PHP class

php
<?php

declare(strict_types=1);

namespace MB\Test\Cron;

class MyCron
{
    public function execute(): void
    {
    }
}

etc/crontab.xml

xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
    <group id="default">
        <job name="mb_test_my_cron" instance="MB\Test\Cron\MyCron" method="execute">
            <schedule>*/5 * * * *</schedule>
        </job>
    </group>
</config>

Released under the MIT License.
This project is not affiliated with, endorsed by, or sponsored by Adobe Inc. "Magento" and "Adobe Commerce" are trademarks of Adobe Inc.
All trademarks and registered trademarks are the property of their respective owners.