简体   繁体   中英

cron job setup in magento

I have refer magentocommerce.com for setting up the cron job. I implemented what i get from that. At first i added cront tab in config.xml file. which i have done for my module "Ownmodule_Autocancel" is shown:

<crontab>
        <jobs>
            <ownmodule_auto_cancel>
                <schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
                <run><model>order/observer::cancelPendingOrders</model></run>
            </ownmodule_auto_cancel>
        </jobs>
</crontab>

Then I opened terminal in linux, given with file permission,

crontab -e

*/5 * * * * php -q /var/www/LIVE/magento/cron.php

Ctrl+x -> Y(for save)

ps aux | grep ping (what i got in the terminal window is)

itss 7746 0.0 0.1 95996 2664 ? Sl 09:29 0:00 /usr/lib/i386-linux-gnu/unity-lens-shopping/unity-shopping-daemon

itss 10106 0.0 0.0 4436 820 pts/0 S+ 11:18 0:00 grep --color=auto ping

kill 7746

ps aux | grep ping (what i got in the terminal window is)

itss 10106 0.0 0.0 4436 820 pts/0 S+ 11:18 0:00 grep --color=auto ping

crontab -l (what i got in the terminal window is)

*/5 * * * * php -q/var/www/LIVE/magento/cron.php

But something is not woking. I don't know how to schedule time in backend cron (scheduled tasks) for 5 min. Please check the above job and give me correct solution. this is done for my module. And also if i missed some other task to done for setting cron job, kindly let me know.

On every cron.php run the system schedules all jobs which should be started in time equal to "Schedule Ahead for" field. Then it checks if all pending(already scheduled) jobs should run, if yes, the it starts the process.

"Generate Schedules Every" is a time interval between schedules generation into queue. "Schedule Ahead for" is a time interval, which determines how forward in time should cronjobs be added into pending queue.

So basically you should set "Schedule Ahead for" the same as "Generate Schedules Every" or a bit greater. The time is up to you, but it should be greater than time you set in your SSH crontab.

To check if crontab is working you can check database table "cron_schedule" to see if there are any jobs scheduled.

Is it "php" or "usr/bin/php" depends on the server. It could be "usr/local/bin/php".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM