简体   繁体   中英

magento cron job and cron_scheduler table

I made magento module which export product in csv file. Now i want to run cronjob every day at 23.55. I set config.xml as it is written in magento cronjob wiki .

My code:

<crontab>
        <jobs>
            <gcompany_runprofilescronjob>
                <schedule>
                    <cron_expr>55 23 * * *</cron_expr>
                </schedule>
                <run>
                    <model>export/export_csv::runprofilescronjob</model>
                </run>
            </gcompany_runprofilescronjob>
        </jobs>
    </crontab> 

I also set cronjob on server. When cronjob run, all cronjobs in magento are stored in database table cron_schedule but not my gcompany_runprofilescronjob. If i set different interval for example:

<cron_expr>*/1 * * * *</cron_expr>

My cronjob is written in database but in execute every minute which i don't want... I want that my function is executed every day at 23.55. Any suggestions what i am doing wrong?

Although this is a very old question, there is no correct answer posted, so let me leave this here for the next guy.

Magento's cron_schedule table is only populated with cron jobs that are scheduled to run in the near future . The reason you're not seeing your cron job in the table is because it only runs once a day, precisely at 23:55. Magento will add this cron job to the cron_schedule table at around 23:45, depending on your server cron job configuration and Magento's cron job settings in System > Configuration > System > Cron . Take note of the Generate Schedules Every and Schedule Ahead for settings, which define how often and how far ahead Magento generates the schedule.

My first step would be to install Fabrizio Branca's AOE Scheduler extension . Fabrizio's extension has a "List View" feature that will show you all of the Cron jobs currently registered with Magento's cron, and when they are scheduled to run. It also allows you to run a cron job immediately in your browser (great for debugging cron jobs), or schedule the job for immediate execution.

If your cron job doesn't appear in AOE Scheduler's list view, there's an issue with the configuration of the cron job. Try clearing the config cache to make sure Magento will parse your config.xml for the latest changes. I assume your XML node is in the appropriate place in the XML document's hierarchy, ie directly under the <config> node?

If your cron job appears in List View and still doesn't run, use the "Generate Schedule" feature to regenerate the cron scheduling tables. Also try running your cron job manually using AOE Scheduler's "Run Now" feature to check for errors or exceptions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM