How to set up multiple cron tab in a custom module in crontab.xml?


I am trying to setup multiple cron jobs in my custom module. I got this

            <job name="alpha" instance="Test\Module\Cron\Checkone" method="execute">
                <schedule>*/2 * * * *</schedule> <!-- here we define time that when function execute  -->
            <job name="beta" instance="Test\Module\Cron\Checktwo" method="execute">
                <schedule>*/5 * * * *</schedule>   

but its working with single job but not working for above code.

First of all, create a file ‘crontab.xml‘ inside the etc folder of your module /app /code /Vendor /Module /etc /crontab.xml.

<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd"> <group id="custom_group_name"> <job name="custom_job_name" instance="Vendor\Module\Cron\Class" method="method"> <schedule>*/30 * * * *</schedule> </job> <job name=.../> </group> </config>

Then, if you specified a custom group, create the file ‘cron_groups.xml‘ inside the same folder /app /code /Vendor /Module /etc /cron_groups.xml

Here you can specify the timings for the cron generation and the history lifetime times.
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/cron_groups.xsd"> <group id="custom_group_name"> <schedule_generate_every>1</schedule_generate_every> <schedule_ahead_for>4</schedule_ahead_for> <schedule_lifetime>2</schedule_lifetime> <history_cleanup_every>10</history_cleanup_every> <history_success_lifetime>60</history_success_lifetime> <history_failure_lifetime>600</history_failure_lifetime> <use_separate_process>1</use_separate_process> </group> </config>