Call a Kohana helper from cron (or any URL)
Asked Answered
S

3

7

I need to call a Kohana helper (or any php MVC framework) from a Cron job.
How can I do this?
The server is Linux, so, I can only think of two possible solutions:
1- Open an URL from the cron job, which hits a controller and does what it has to do.
2- Call a Kohana controller without passing through the web server, but with the PHP CLI. (is that even possible? I don't think so, it might need the web server environment to work)

Know a solution? Thanks

Suitable answered 12/11, 2009 at 13:25 Comment(0)
O
10

with the kohana framework you can pass the "uri" as a command line parameter:

/path/to/index.php controller/method/param

you might want to try that, you will definitely need a controller but you dont need to use wget or curl

Ossiferous answered 12/11, 2009 at 15:28 Comment(1)
That syntax is for K2, for K3 you need php index.php --uri="uri/path"Shorthorn
C
1

Can't you just curl or wget the URL?

Charade answered 12/11, 2009 at 13:33 Comment(1)
I think this can work in many cases, however if your cron job takes a very long time to run, than maybe your curl will timeout.Altamira
B
1

You can do it as:

lynx > /dev/null -dump "URL"
wget -q -O /dev/null "URL"
fetch -o /dev/null "URL"
curl -s -o /dev/null "URL"

just replace URL

Bumptious answered 1/11, 2010 at 14:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.