简体   繁体   中英

php single file cron job

how can I create a single PHP file that calls all files within the same folder sequentially.
Im trying to create a simpler way to run all my php files ( Cron Jobs).
The way I am doing now is as follow :

Batch file

start /wait C:\xampp\php\php.exe -f C:\xampp\99003.php
start /wait C:\xampp\php\php.exe -f C:\xampp\78367.php
start /wait C:\xampp\php\php.exe -f C:\xampp\40937.php
//ect... I have more than 200 files I want to run one after another...

All files name are 5 digits number. I just get lost sometimes when adding or removing files.. Thanks

For loop:

for /d %i in ("C:\xampp\*.php") do start /wait C:\xampp\php\php.exe -f %~fi

Sorry I lack information about all this atm. $~fi is the fully qualified path name.

Hit this google link: https://www.google.de/search?q=windows+for+command+line+stackoverflow

You could also write a PHP script which calls all other PHP files, but PHP is different from command line (bat) in the way memory is used, scripts might block which you have to circumvent (using proc_open() ), you would encounter timeouts.. set_time_limit(0); .

Using a batch file for your purpose seems a good approach, figure the parameters of the command line for the for command and you can do this in 1-3 lines of code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM