问题
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