简体   繁体   中英

PHP CLI program run in background

I am using RabbitMQ Messaging service to run some background services. The problem I am facing is that I have keep open my command line which runs a script continuously

php receive_messages.php

Is it possible that these scripts run in background as soon as I start my rabbit MQ server or WAMP?

In linux I can use some programs like forever but in windows ???

Try running a PHP script in a while loop and run in with screen.

Example code:

#!/usr/bin/php
ignore_user_abort(true);    
set_time_limit(0); 

while(true) { 
   echo 'Running..'; // Code here
   sleep (60); // Sleep 60 seconds
}

Command for cmd (first start cmd by pressing alt + r and then type cmd) with:

start /B php.exe myscript.php 

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