How to setup a custom cron job in opencart?

放肆的年华 提交于 2021-01-29 10:55:12

问题


Can anyone tell me how can I setup a custom cron job in opencart?

I have Url in below format and when I am manually hit this url it works perfectly now I want to make it dynamic on cron schedule basis.

I have setup cron job in https://cron-job.org/en/ using below URL and it works fine but I'm not sure whether it is the right way or not?

> http://www.yourstore.com/admin/index_for_cron.php?route=module/modulename/function

Thanks in advance..!


回答1:


There you'll find instruction: http://docs.opencart.com/en-gb/extension/cron/




回答2:


If you able to setup cron tasks on your web-server, you are always can use curl:

 curl -s "http://www.yourstore.com/admin/index_for_cron.php?route=module/modulename/function" >/dev/null

I'm also managed to run my custom modules for OpenCart3 with command like this:

 cd /path/to/your/site && QUERY_STRING="route=module/modulename/function" php -r 'parse_str($_SERVER["QUERY_STRING"],$_GET);include "index.php";'

(But in this case you need to consider file permissions and run task under appropriate user.)



来源:https://stackoverflow.com/questions/52529945/how-to-setup-a-custom-cron-job-in-opencart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!