Running cron in magento

Setting cron
In your command line use this command
sudo crontab -e
//add your cron
*/1 * * * * /bin/sh /var/www/html/canon_2016/cron.sh >> /var/log/myjob.log 2>&1

sudo crontab -l (shows the list of cron)


To test cron is running or not

 try {
    Mage::getConfig()->init()->loadEventObservers('crontab');
    Mage::app()->addEventArea('crontab');
    Mage::dispatchEvent('default');

$log = fopen(__FILE__.'.log', 'a');
fwrite($log, date("Y-m-d H:i:s").PHP_EOL);
fclose($log);
} catch (Exception $e) {
    Mage::printException($e);
}


place this code at the bottom of cron.php file in magento root directory,it will create cron.php.log file,which will show when the cron job start

Comments

Popular Posts

Magmi Single and Multiple Category Importer