Php Cron Job on XAMPP Windows
Obviously you set crons at OS level not at Application level. Although, Like on Unix/Linux, You can set CRON at windows platform too by using Task Schedular ( All Programs->Accessories->System Tools -> Task Schedular )
. I think you should go for VPN or Dedicated Servers for crons to set as it needs access to system resources privately.
Apart from it, Syntax for Crontab command
(unix/linux) goes like this:
1 2 3 4 5 /root/backup.sh
1: Minute (0-59)
2: Hours (0-23)
3: Day (0-31)
4: Month (0-12 [12 == December])
5: Day of the week(0-7 [7 or 0 == sunday])
/path/to/command - Script or command name to schedule
Run Cron Job on PHP Script, on localhost in Windows
recently I had sort of problems to run a cron job on a php script on localhost (WAMP server) in windows 7, when I was on a test to chronically fetch some links from www out there.
By the way I am sharing this for anyone that is on the same thing.
You will need a shellscript to run chronically, using Windows Task Scheduler. Also you will need a batch script (script.bat) to call the php.exe and run your php script (here called as my_process.php
)
shellscript.vbs
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "C:\path\to\script\script.bat" & Chr(34), 0
Set WinScriptHost = Nothing
script.bat
"C:\wamp\bin\php\php5.4.12\php.exe" -f "C:\wamp\www\website\my_process.php"
Now, we are ready to set the Windows Task Scheduler to run shellscript.vbs at the required time interval:
- Open Task Scheduler from windows Start menu
- Go to Action menu and hit Create Task...
- in General tab, fill the Name and Description fields as you want
- in Triggers tab, hit New button.
- from Begin the Task dropdown, select On a schedule and choose Daily
- from Advanced settings section, select Repeat task every as you want and set for a duration on Indefinitely.
- on Actions tab, from Action dropdown, select Start a program.
- on the Program\script box, enter path to shellscript.vbs like C:\path\to\shellscript.vbs.
- leave Add argumentts (optional) section empty.
- in Start in (optional) box, enter parent directory of shellscript.vbs like
C:\path\to\
. - Hit upvote on this tutorial :) Have fun.
Related Topics
How to Log into Joomla Through an External Script
Differencebetween Is_A and Instanceof
Place PHP Results Inside HTML Page
Jquery Tablesorter Index Column Insert
Ajax/PHP - How to Get Posted Data to Load into a Modal on the Same Page
Php: How to Get a List of Classes That Implement Certain Interface
What Are the Differences Between "PHP Artisan Dump-Autoload" and "Composer Dump-Autoload"
In Laravel How to Add Values to a Request Array
Warning: Cannot Modify Header Information - Headers Already Sent
Passing Value from PHP Script to Python Script
Differences and Similarities Between Lumen and Laravel
How to Upload an Image as Attachment with Slack API
How to Display All the Images Stored Inside a Database
Only Variables Should Be Passed by Reference In... on Line 13 Fail
Select MySQL Based Only on Month and Year