0

I am little bit confused with the Magento 1 cron jobs. I am creating a custom module and I need to sync data in third party API with cron. Firstly I set up a cron job on my server like this:

*/5 * * * * /bin/bash /path/to/magento/cron.sh

According to me this cron will run in every 5 min and will read/schedule magento crons from my custom module config file.

Here is the code of my custom module config file for cron:

<crontab>
    <jobs>
        <Namespace_ModuleName_sync_abandon_cart>
            <schedule>
                <cron_expr>*/1 * * * *</cron_expr>   
            </schedule>
            <run>
                <model>abandon/observer::syncAbandonCart</model>
            </run>
        </Namespace_ModuleName_sync_abandon_cart>
    </jobs>
<crontab>

After setting up cron in config file for my module, I can see there in magento admin configuration. I have cronjob settings like this:

enter image description here

Now, I am confused from above three cron settings that when my custom module cron will run? I actually want some clarity for the cron job setup in magento 1.

Thanks in advance.

2
  • cron expression should be like <cron_expr>*/1 * * * *</cron_expr> to run the defined method at every minute. check more details at crontab.guru. The configuration settings shown by you is for whole Magento cron status. I hope after updating cron expression it would be working. Dec 6, 2018 at 8:23
  • Thanks @HimmatPaliwal but I exactly want to know that frequencies of cronjob for above three settings. Dec 6, 2018 at 8:46

1 Answer 1

0

Please find the meaning of all three schedules below:

  1. The cron set at server, in your case its */5 * * * * /bin/bash /path/to/magento/cron.sh would be running every 5 minutes and check for all the cron schedules added via magento code. Please set it to run every minute to get cron properly defined in your custom module (its set to run every minute).

  2. In your custom module you set cron to run every minute, it would be running every minute, but at server its set to run every 5 minutes so only one job will run successfully, other 4 may be missed in your case. The settings made at module/code level (All other crontabs along with your custom module) will be executed by cron set at server.

    <jobs>
        <Namespace_ModuleName_sync_abandon_cart>
            <schedule>
                <cron_expr>*/1 * * * *</cron_expr>   
            </schedule>
            <run>
                <model>abandon/observer::syncAbandonCart</model>
            </run>
        </Namespace_ModuleName_sync_abandon_cart>
    </jobs>
    
  3. The configuration settings shown by you will give you the status of cron schedules of whole your Magento setup if they have been run successfully or failed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.