Reputation: 29
I am trying to set up a cron job on my localhost to call a php
script every half an hour 24/7. Following are my steps:
1) I have created a cron.php file to call myscript.php
:
<?php
echo exec('*/30 * * * * C:\BitNami\wampstack-5.4.21-0\php -f C:\BitNami\wampstack-5.4.21-0\apache2\htdocs\myscript.php');
?>
2) Created a cron.bat file to run the cron.php
on browser:
"C:\Program Files\Mozilla Firefox\firefox.exe" "localhost\cron.php"
3) Then I have set up a windows 7 task scheduler to call cron.bat
every day.
I welcome any idea on how to set up a cron job as my approach doesn't do anything.
Thanks
Upvotes: 0
Views: 9415
Reputation: 725
dude, you cannot define cron jobs in wamp, the cron is a linux feature and you are running the wamp on windows.
you can run the script from the command line (of from cygwin, much better), something like "/php.exe " but you cannot define crons on wamp
but you can setup the scheduler to run a .bat file that contains the next code cd/ cd "Program Files (x86)" cd GnuWin32 cd bin wget.exe http:// localhost/... (your file) echo DONE
Upvotes: 0
Reputation: 380
you don't need to creat .bat file to run php script
follow the step to setup cron job for php interpreter..
step 1- Then I have set up a windows 7 task scheduler to call php script by giving path of php interpreter like C:\xampp\php\php.exe filename.php by setting desired interval
Upvotes: 0
Reputation: 76847
This is not an answer, but only pointers you need to check before you proceed further.
Crons are available only on unix systems, not windows.
While debugging cron or anything similar, schedule them for every minute or (any such acceptable smaller frequency), and once they work every minute, only then schedule them for the original frequencies. That will save you some time during debugging.
Its an incorrect call to exec. You don't have to pass all those *
in it
Since this is windows, You want to do php.exe
and not C:\BitNami\wampstack-5.4.21-0\php -f
which would have been done in linux (with proper path)
Your .bat
file is currently scheduled daily, you need to schedule it every half hour.
Upvotes: 1