Überschreiben der Magento default CronJobs

Magento ermöglicht es, benutzerdefinierte Aufgaben (cronjobs) mittels der config.xml in den einzelnen Modulen zu planen. Das geschieht in ähnlicher Weise wie in der UNIX-Welt.

Um diese cronjobs besser verwalten zu können, ist es dabei recht Sinnvoll diese an einer zentralen Stelle vorzufinden. Wir haben dazu z.B. alle cronjobs unter /app/code/community/DigitalVertraut/base/config.xml zusammengefasst.

<config>
...
    <crontab>
        <jobs>
            <!-- BEGIN OVERRIDE core/Mage/Log/etc/config.xml: -->
            <log_clean>
                <run>
                    <model>log/cron::logClean</model>
                </run>
            </log_clean>
            <!-- END core/Mage/Log/etc/config.xml: -->
            
            <!-- BEGIN OVERRIDE core/Mage/Catalog/etc/config.xml:  -->
            <catalog_product_index_price_reindex_all>
                <schedule><cron_expr>0 3 * * *</cron_expr></schedule>
                <run><model>catalog/product_indexer_price::reindexAll</model></run>
            </catalog_product_index_price_reindex_all>
            <!-- END OVERRIDE core/Mage/Catalog/etc/config.xml: -->
            
            <!-- BEGIN OVERRIDE core/Mage/Newsletter/etc/config.xml: -->
            <newsletter_send_all>
                <schedule><cron_expr>0 3 * * *</cron_expr></schedule>
                <run><model>newsletter/observer::scheduledSend</model></run>
            </newsletter_send_all>
            <!-- END OVERRIDE core/Mage/Newsletter/etc/config.xml: -->
            
            <!-- BEGIN OVERRIDE core/Mage/ProductAlert/etc/config.xml: -->
            <catalog_product_alert>
                <run>
                    <model>productalert/observer::process</model>
                </run>
            </catalog_product_alert>
            <!-- END OVERRIDE core/Mage/ProductAlert/etc/config.xml: -->
            
            <!-- BEGIN OVERRIDE core/Mage/Ideal/etc/config.xml: -->
            <trasaction_status_check>
                <schedule><cron_expr>0 */1 * * *</cron_expr></schedule>
                <run><model>ideal/advanced::transactionStatusCheck</model></run>
            </trasaction_status_check>
            <!-- END OVERRIDE core/Mage/Ideal/etc/config.xml: -->
            
            <!-- BEGIN OVERRIDE core/Mage/Sitemap/etc/config.xml: -->
            <sitemap_generate>
                <run>
                    <model>sitemap/observer::scheduledGenerateSitemaps</model>
                </run>
            </sitemap_generate>
            <!-- END OVERRIDE core/Mage/Sitemap/etc/config.xml: -->
            
            <!-- BEGIN OVERRIDE core/Mage/Sales/etc/config.xml: -->
            <sales_clean_quotes>
                <schedule><cron_expr>0 3 * * *</cron_expr></schedule>
                <run><model>sales/observer::cleanExpiredQuotes</model></run>
            </sales_clean_quotes>
            <!-- END OVERRIDE core/Mage/Sales/etc/config.xml: -->
            
            <!-- BEGIN OVERRIDE core/Mage/CatalogIndex/etc/config.xml: -->
            <catalogindex_reindex_all>
                <schedule><cron_expr>0 3 * * *</cron_expr></schedule>
                <run><model>catalogindex/observer::reindexAll</model></run>
            </catalogindex_reindex_all>
            <catalogindex_run_queued>
                <schedule><cron_expr>* * * * *</cron_expr></schedule>
                <run><model>catalogindex/observer::runQueuedIndexing</model></run>
            </catalogindex_run_queued>
            <!-- END OVERRIDE core/Mage/CatalogIndex/etc/config.xml: -->
            
            <!-- BEGIN OVERRIDE core/Enterprise/TargetRule/etc/config.xml: -->
            <enterprise_targetrule_index_reindex>
                <schedule><cron_expr>0 3 * * *</cron_expr></schedule>
                <run><model>enterprise_targetrule/index::cron</model></run>
            </enterprise_targetrule_index_reindex>
            <!-- END OVERRIDE core/Enterprise/TargetRule/etc/config.xml: -->
            
            <!-- BEGIN OVERRIDE core/Enterprise/Logging/etc/config.xml: -->
            <enterprise_logging_rotate_logs>
                <schedule><cron_expr>0 3 * * *</cron_expr></schedule>
                <run><model>enterprise_logging/observer::rotateLogs</model></run>
            </enterprise_logging_rotate_logs>
            <!-- END OVERRIDE core/Enterprise/Logging/etc/config.xml: -->
            
            <!-- BEGIN OVERRIDE core/Enterprise/Staging/etc/config.xml: -->
            <enterprise_staging_automates>
                <schedule><cron_expr>0 3 * * *</cron_expr></schedule>
                <run><model>enterprise_staging/observer::automates</model></run>
            </enterprise_staging_automates>
            <!-- END OVERRIDE core/Enterprise/Staging/etc/config.xml: -->
            
            <!-- BEGIN OVERRIDE core/Enterprise/GiftCardAccount/etc/config.xml: -->
            <enterprise_giftcardaccount_update_states>
                <schedule><cron_expr>0 3 * * *</cron_expr></schedule>
                <run><model>enterprise_giftcardaccount/cron::updateStates</model></run>
            </enterprise_giftcardaccount_update_states>
            <enterprise_giftcardaccount_generage_codes_pool>
                <schedule><cron_expr>0 3 * * *</cron_expr></schedule>
                <run><model>enterprise_giftcardaccount/pool::applyCodesGeneration</model></run>
            </enterprise_giftcardaccount_generage_codes_pool>
            <!-- END OVERRIDE core/Enterprise/GiftCardAccount/etc/config.xml: -->
        </jobs>
    </crontab>
...
</config>


Alle im System vorhanden cronjobs erhalten sie mit den folgenden paar Zeilen. So können Sie auch leicht testen, ob Ihre Änderungen erfolgreich vom System übernommen wurden.

include 'app/Mage.php';

Mage::app();

$crontab = Mage::getConfig()->getNode('crontab/jobs');

print_r($crontab);

Unter 1.6.0.2 ergibt sich z.B. damit:


Mage_Core_Model_Config_Element Object
(
    [currency_rates_update] => Mage_Core_Model_Config_Element Object
        (
            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => directory/observer::scheduledUpdateCurrencyRates
                )

        )

    [catalog_product_index_price_reindex_all] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => 0 2 * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => catalog/observer::reindexProductPrices
                )

        )

    [catalogrule_apply_all] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => 0 1 * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => catalogrule/observer::dailyCatalogUpdate
                )

        )

    [sales_clean_quotes] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => 0 0 * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => sales/observer::cleanExpiredQuotes
                )

        )

    [aggregate_sales_report_order_data] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => 0 0 * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => sales/observer::aggregateSalesReportOrderData
                )

        )

    [aggregate_sales_report_shipment_data] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => 0 0 * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => sales/observer::aggregateSalesReportShipmentData
                )

        )

    [aggregate_sales_report_invoiced_data] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => 0 0 * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => sales/observer::aggregateSalesReportInvoicedData
                )

        )

    [aggregate_sales_report_refunded_data] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => 0 0 * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => sales/observer::aggregateSalesReportRefundedData
                )

        )

    [aggregate_sales_report_bestsellers_data] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => 0 0 * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => sales/observer::aggregateSalesReportBestsellersData
                )

        )

    [aggregate_sales_report_coupons_data] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => 0 0 * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => salesrule/observer::aggregateSalesReportCouponsData
                )

        )

    [paypal_fetch_settlement_reports] => Mage_Core_Model_Config_Element Object
        (
            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => paypal/observer::fetchReports
                )

        )

    [log_clean] => Mage_Core_Model_Config_Element Object
        (
            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => log/cron::logClean
                )

        )

    [aggregate_sales_report_tax_data] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => 0 0 * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => tax/observer::aggregateSalesReportTaxData
                )

        )

    [sitemap_generate] => Mage_Core_Model_Config_Element Object
        (
            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => sitemap/observer::scheduledGenerateSitemaps
                )

        )

    [catalog_product_alert] => Mage_Core_Model_Config_Element Object
        (
            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => productalert/observer::process
                )

        )

    [persistent_clear_expired] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => 0 0 * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => persistent/observer::clearExpiredCronJob
                )

        )

    [newsletter_send_all] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => */5 * * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => newsletter/observer::scheduledSend
                )

        )

    [xmlconnect_notification_send_all] => Mage_Core_Model_Config_Element Object
        (
            [schedule] => Mage_Core_Model_Config_Element Object
                (
                    [cron_expr] => */5 * * * *
                )

            [run] => Mage_Core_Model_Config_Element Object
                (
                    [model] => xmlconnect/observer::scheduledSend
                )

        )

)

Keine Kommentare »

Noch keine Kommentare

RSS-Feed für Kommentare zu diesem Beitrag. | TrackBack URI

Hinterlasse einen Kommentar

XHTML ( You can use these tags): <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .

CAPTCHA-Bild
* Bitte tragen sie den Code in das Feld ein.
Diese Seite Drucken