Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Batch File to run PHP file

Tags:

php

I have PHP script that fetches information from a backend server and saves into a database.

I am using wamp server and mysql. Now how do I make this run periodically (every 1 hour) without user interaction? I thought of using Windows Batch file. Is there any other way?

How do I execute a PHP file in Windows Batch file?

like image 439
aandroidtest Avatar asked Jan 23 '13 02:01

aandroidtest


1 Answers

To execute PHP from a batch file, follow these 3 simple steps:

  1. Add PHP to your PATH variable.

  2. Create a batch file that calls PHP with your file:

    php path\to\file.php
    

    and name your file whatever.bat.

  3. Now its just a matter of setting up a task in Windows Task Scheduler to run your batch file periodically.

like image 98
Joseph Silber Avatar answered Oct 18 '22 12:10

Joseph Silber