Search code examples
phpwindowsautomationscheduled-tasksscheduling

Schedule and execute a PHP script automatically


I have written a PHP script which generates an SQL file containing all tables in my database. What I want to do is execute this script daily or every n days. I have read about cron jobs but I am using Windows. How can I automate the script execution on the server?


Solution

  • You'll need to add a scheduled task to call the URL.

    First of all, read up here: MS KB - this is for Windows XP.

    Second, you'll need some way to call the URL - i'd recommend using something like wget - this way you can call the URL and save the output to a file, so you can see what the debug output is. You can get hold of wget on this page.

    Final step is, as Gabriel says, write a batch file to tie all this up, then away you go.

    e: wget is pretty simple to use, but if you have any issues, leave a comment and I'll help out.

    ee: thinking about it, you don't even really need a batch file, and could just call wget directly..