<?xml version="1.0"?> <config> <modules> <Magenticians_Mymodule> <version>0.0.1</version> </Magenticians_Mymodule> </modules> </config>Now that the configuration of module is done, just activate it. Create Magenticians_Mymodule in app/etc/modules and paste the following code in it:
<?xml version="1.0"?> <config> <modules> <Magenticians_Mymodule> <active>true</active> <codePool>local</codePool> </Magenticians_Mymodule> </modules> </config>Now, to check if the module is activated, go to System → Configuration → Advanced → Advanced, and check the list of disabled module output.
<?xml version="1.0"?> <config> <modules> <Magenticians_Mymodule> <version>0.0.1</version> </Magenticians_Mymodule> </modules> <crontab> <jobs> <custom_cron_task> <schedule> <cron_expr>*/5 * * * *</cron_expr> </schedule> <run> <model>cron/cron::customtask</model> </run> </custom_cron_task> </jobs> </crontab> <global> <models> <cron> <class>Magenticians_Mymodule_Model</class> </cron> </models> </global> </config>In the code above, we have scheduled a cron job to run every five minutes. In <run>, I have defined a function customtask. Now create Cron.php in app/code/local/Magenticians/Mymodule/Model and paste the following code in it:
<?php class Magenticians_Mymodule_Model_Cron { public function customtask() { // send email $mail = Mage::getModel('core/email') ->setToEmail('user@email.com') ->setBody('Body of the Automated Cron Email Goes Here') ->setSubject('Subject: Cron Task (every 5 minutes) '.date("Y-m-d H:i:s")) ->setFromEmail('admin@example.com') ->setFromName('Your Store Name') ->setType('html'); $mail->send(); } }And you’re all done! Just add this line in your crontab file: */5 * * * * sh /path/to/your/magento/store/cron.sh Note: Don’t forget to replace /path/to/your/magento/store with the actual path of your Magento installation.
*/5 * * * * sh /path/to/your/magento/store/cron.php
To avoid this issue, run this instruction as it will search for PHP interpreter itself: */5 * * * * sh /path/to/your/magento/store/cron.sh
2. Use Correct Email Address Make sure you have added correct email address of both sender and receiver to setup Magento cron job: setToEmail(‘user@email.com’) setFromEmail(‘admin@example.com’) If any error occured in the execution of Magento cron job, you will be notified via email with complete details. Q2. Which cron script is best to run? cron.php or cron.sh? This is the most very common confusion, cron.php and cron.sh both scripts used for the same purpose but sometimes you can face error in running cron.php script due to the PHP installed on some different path. Whereas on running cron.sh it will search PHP interpreter by itself. So its better to use cron.sh rather cron.php for setting up Magento cron job. Your greatest possible competitive advantage can be your clients and the interactions they have with… Read More
Digital marketing KPIs are measurable values that marketing teams use to track progress toward desired… Read More
In today's digital age, fraud poses a significant threat to businesses of all sizes. As… Read More
Financial crimes continue to evolve and proliferate in our increasingly digital, global economy. From complex… Read More
In the highly competitive modern workplace, trust, and employee loyalty are crucial factors for long-term… Read More
In the ever-evolving world of small business developing and implementing effective marketing strategies is critical to… Read More