简体   繁体   English

PHP的单文件Cron工作

[英]php single file cron job

how can I create a single PHP file that calls all files within the same folder sequentially. 如何创建一个PHP文件,该文件依次调用同一文件夹中的所有文件。
Im trying to create a simpler way to run all my php files ( Cron Jobs). 我试图创建一种更简单的方式来运行我所有的php文件(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. 所有文件名均为5位数字。 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. 抱歉,我缺少有关所有这些atm的信息。 $~fi is the fully qualified path name. $〜fi是完全限定的路径名​​。

Hit this google link: https://www.google.de/search?q=windows+for+command+line+stackoverflow 点击此Google链接: 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); 您还可以编写一个PHP脚本来调用所有其他PHP文件,但是PHP在使用内存的方式上不同于命令行(bat),脚本可能会阻塞您必须规避的地方(使用proc_open() ),您会遇到超时问题.. 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. 为您的目的使用批处理文件似乎是一种好方法,为for命令指定命令行的参数,然后可以在1-3行代码中执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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