Page 1 of 1

Setup cron job?

Posted: Wed Sep 04, 2013 8:07 am
by sitesrus
Trying to use a cron job (wget, php and script using curl, etc.) to run module code in the front end. Everything works fine when visiting the url in my browser and the module runs fine updating the DB. However when I use wget or curl+script manually nothing seems to work.

Is there a reason for this? Why wouldn't wget and the url work the same as my browser?


PS. This is actually kind of weird, it's a multi-lingual site and it tries to store cookies. The output in wget and lynx suggests it is working...but the DB does not update at all.

Re: Setup cron job?

Posted: Thu Sep 05, 2013 9:04 pm
by sitesrus

Has no one ever tried this or have experience with this? Does the system for some reason not support this?

Any help would be great...

Re: Setup cron job?

Posted: Thu Sep 05, 2013 9:15 pm
by CZechBoY
wget doesn't have cookies (sessions too) so you can't visit some page in backend
but you wrote you are running script in frontend - without login and session required right?

copy the url to anonymous panel in the browser and watch what it will do and don't

Re: Setup cron job?

Posted: Thu Sep 05, 2013 9:29 pm
by OpenCart Addons

Try this:

Code: Select all

wget -q -O /dev/null ""
Change feed/feed to the route of the function.

You have to run the script from the front end, I would suggest setting up a password and username in the file and calling it in the url using &password=password&username=username for security reasons.


Re: Setup cron job?

Posted: Thu Sep 05, 2013 9:51 pm
by sitesrus

No the code requires no login or session and yes it's on the front end, I'm not worried about users or bots hitting it themselves as it will just initiate tasks which isn't a bad thing and actually relieve server load with more processing of tasks more frequently.

I have tried using wget with -O but when I look at the DB nothing changes, it only changes when I visit from a browser on the front end. I run wget from a linux terminal and although the output makes me thing it worked, I see no change in the DB which the script should update.

The feeds stuff, is that in open cart already? Maybe I should look at that code and see if I am missing something...

Re: Setup cron job?

Posted: Thu Sep 05, 2013 11:20 pm
by OpenCart Addons
Feeds are just another extension type that you can install on your system.

OpenCart comes with a couple different Google feeds by default. You can see them under:
Admin CP > Extensions > Feeds


Re: Setup cron job?

Posted: Fri Sep 06, 2013 8:02 am
by sitesrus
I closely inspected the output of wget and at a glance it looked like it was working, but when I look closer I see a discrepency. I dumped out a php date time to see and when I use browser it's real when I use wget it's do I get it to run properly and not from cache?

Is it open cart cache? VQMOD cache? Something third party? What would be causing wget to get an old stale version or read something out of cache? Like I said, it works fine via web browser so with wget it may not be running any code just getting a cached HTML version?

Re: Setup cron job?

Posted: Mon Sep 09, 2013 4:10 am
by marwan83
Any solution for this?

Re: Setup cron job?

Posted: Sun Jan 26, 2014 4:10 am
by Jsf
maybe someone knows how to cron job admin functions?

I try to curl, but without success :/

Re: Setup cron job?

Posted: Sun Jan 26, 2014 9:18 am
by billynoah
i could be more helpful if you could describe what exactly it is you're trying to do. for the most part if i was setting up a cron job to do anything with opencart i'd just write it to issue a query to the db directly. though this may not be appropriate in every case, it can accomplish 99% of the tasks you'd want.

Re: Setup cron job?

Posted: Mon Mar 02, 2015 5:32 am
by openmandrake
As I had a similar requirement several times, I put my ideas into a lightweight commandline tool called OCOK. Which solves amongst others the issue of calling Opencart controllers via command line and thus as cron jobs...

All you need to do is createing a controller in the admin package and call it with the ocok run command from the terminal.

I think you shouldn't use URLs for cron jobs, which are world callable. Hiding them behind the admin only allows the commandline calling them.

Documentation on installation and usage can be found here. Feel free to contact me if you have problems, feedback or suggestions...