Question

How to run controller action in Cron Job?

I am trying to run cron every five Minute, but cron is not working.

I put the code below, Please check :-

*/5 * * * * root wget -O - http://www.example.com/index.php/test/index/testtransact > /tmp/testtransact.log 2>&1  
Was it helpful?

Solution 2

Today, I got the answer of the question we can run this by using curl -I and give your url I wrote down side find:-

*/5 * * * * root curl -I http://www.example.com/index.php/test/index/testtransact > /tmp/testtransact.log 2>&1

Now it's successfully work.

OTHER TIPS

You can refer below answer from Joseph, refer link : https://stackoverflow.com/questions/5661513/how-to-setup-magento-cron-job-and-init-action-of-the-controller

As far as I have ever seen, you cannot directly run controller actions in a cronjob, since that is not a terribly sensible thing to do outside of a user context. The easiest thing to do here is to put that functionality you need into a model and call that from the cronjob.

More information on the controller action you want to fire would be helpful in giving further advice.

Hope that helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top