Reputation: 405
I am new to Magento 1.9
. I have my own custom API which read last modified Product stock and do some updates. I need to make this API run every five minutes . Please help.
Upvotes: 1
Views: 1555
Reputation: 391
Here i mentioned module.
create Stackoverflow_Cronshedule.xml under app\etc\modules\
<?xml version="1.0"?>
<config>
<modules>
<Stackoverflow_Cronshedule>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</Stackoverflow_Cronshedule>
</modules>
</config>
create etc.xml under app\code\local\Stackoverflow\Cronshedule\etc\
<?xml version="1.0"?>
<config>
<modules>
<Stackoverflow_Cronshedule>
<version>0.1.0</version>
</Stackoverflow_Cronshedule>
</modules>
<global>
<models>
<cronshedule>
<class>Stackoverflow_Cronshedule_Model</class>
<resourceModel>cronshedule_mysql4</resourceModel>
</cronshedule>
</models>
</global>
<crontab>
<jobs>
<cronshedule_lastmodifiedproduct>
<schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
<run><model>cronshedule/cron::lastModifiedProduct</model></run>
</cronshedule_lastmodifiedproduct>
</jobs>
</crontab>
</config>
Create Cron.php file under app\code\local\Stackoverflow\Cronshedule\Model\
<?php
class Stackoverflow_Cronshedule_Model_Cron{
public function lastModifiedProduct(){
// update last modified product
}
}
At last, Set cron task for every minute in your cPanel for your /cron.php file.
Upvotes: 2