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

dusan
  • 9,104
  • 3
  • 35
  • 55
Petruza
  • 11,744
  • 25
  • 84
  • 136

3 Answers3

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

Nodren
  • 558
  • 2
  • 4
  • 11
1

Can't you just curl or wget the URL?

Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
  • 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. – Tamás Pap May 06 '13 at 10:02
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

Alex Rashkov
  • 9,833
  • 3
  • 32
  • 58