Magento’s cron entry point is the cron.php script in your Magento root. You’ll need to setup an OS crontab entry hit this script, which you appear to have done already.
How the cron works?
Every time the cron.php script is hit three things happen:
- Schedule: Magento parses the merged config.xml files for … jobs entries, reading their cron_expr elements for detail on how often they should be run. Magento then populates the cron schedule table with jobs that should be executed in the future, along with timestamps for when they should be run. The extent into the future that Magento does this is configurable in the admin.
- Execute: Magento reads the cron schedule table for jobs that need to be executed this very second and jobs that should have already been executed, i.e. with timestamps in the past, that haven’t expired. The expiry limit is also a parameter configurable in the admin.
- Cleanup: Magento goes through the schedule table deleting jobs that have been completed, or missed (due to the deadline).
Duplicate runs?
You raise an interesting point. What happens if you have a 10 minute cron scheduled in Magento, but cron.php is only guaranteed to be hit every 15 minutes. It appears that Magento would run your Magento jobs twice, in some cases:
HH:00 -> HH:50 and HH:00
HH:15 -> HH:10
HH:30 -> HH:20 and HH:30
HH:45 -> HH:40
I’ve only read the code, and that’s what appears to happen. The best way to find out would be, of course, to run it and find out. If you want to avoid the issue, in most cases, then increase the cron.php execution frequency to every 5 minutes, which is what we do.
you can adding these to the bottom of cron.php will make it write out cron.php.log on execution with the datetime.
<?php 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); } ?>
OR
Testing your code:
If you want to test if your cron is actually working without waiting an age, set the cron_expr to execute every minute, or clear out your cron schedule table then hit cron.php twice (once to generate the schedule, and again to run the job).
If you want to just test that your model is working, you could setup a below test script, and run that.
<?php require_once '../../../../Mage.php'; Varien_Profiler::enable(); Mage::setIsDeveloperMode(true); ini_set('display_errors', 1); umask(0); Mage::app(); $obj = Mage::getModel('shipwire/api_inventorysynch'); $obj->submitRequest(); ?>
Source: https://www.nicksays.co.uk/testing-magento-modules