简体   繁体   中英

how can I run php from command line constantly

I'm doing this in CMD :

php -f index.php I want to run this code constantly in CMD even error happen, How can I make force to run this command ?

use this.

ignore_user_abort(1); // Set whether a client disconnect should abort    script execution
set_time_limit(0); //Limits the maximum execution time, in this case it runs until the process finishes or apache restart.

If you want to rerun the application regardless of it crashing or being interrupted intentionally something simplistic like this will do:

@echo off
:endless
php -f index.php
goto endless

Put this into foo.cmd and then run foo

If you're on a Linux sever, the following will work:

#!/bin/bash
while :
do
   php index.php
done

You execute by running sh ./test.sh

For windows; the following as a .bat file will also work

@echo off
cls
:start
  php index.php
goto start

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