0

I found this post here : Run Cron Job on PHP Script, on localhost in Windows which is working perfectly. Instead of a PHP file I want to run an URL instead, like http://localhost/test-cron-job

I tried to simply change this line here:

"C:\xampp\php\php.exe" -f "C:\Users\Matthew\Documents\Work\cronjob\my_script.php"

to this:

"C:\xampp\php\php.exe" -f "http://localhost/test-cron-job"

But it is not working at all. What can I do to make this work?

Community
  • 1
  • 1
Matthieu Boisjoli
  • 1,057
  • 2
  • 11
  • 17

1 Answers1

2

It doesn't work because php.exe is supposed to execute a PHP file. When you point it to a URL it doesn't know what to do.

What you need is something like curl for Windows and then you can make a HTTP request:

curl http://localhost/test-cron-job
Luís Cruz
  • 14,780
  • 16
  • 68
  • 100
  • Hello there, I tried what you were asking me. But when I put this curl "http://localhost/test-cron-job" in my script.bat, nothing happen. But, if I go to the command prompt as an Administrator and then I type curl "http://localhost/test-cron-job", this is executing perfectly. What is wrong? Did I miss something? – Matthieu Boisjoli May 30 '15 at 18:11
  • @MatthieuBoisjoli Most likely, the user from your webserver doesn't have permissions to execute the `curl` executable. Take a look at [this answer](http://stackoverflow.com/a/29683406/908174) to know how to set permissions in windows files. – Luís Cruz May 30 '15 at 18:15