简体   繁体   中英

check php-fpm running windows server

i was working at Linux with php-fpm

and moved to windows server

i was able to check url file php by ssh command

/usr/bin/curl --head  

if not found head at url restart php-fpm automatically with corn 2m

since i moved to windows am not able to do same

i found solution

script will check if a service is running and if it is not running it will start it. Only change the variable ServiceName to the name of the service you would like to check, ie Windows Update is wuauserv.

PowerShell

@ECHO OFF 
SET SvcName=ServiceName 

SC QUERYEX "%SvcName%" | FIND "STATE" | FIND /v "RUNNING" > NUL && ( 
    ECHO %SvcName% is not running  
    ECHO START %SvcName% 

    NET START "%SvcName%" > NUL || ( 
        ECHO "%SvcName%" wont start  
        EXIT /B 1 
    ) 
    ECHO "%SvcName%" is started 
    EXIT /B 0 
) || ( 
    ECHO "%SvcName%" is running 
    EXIT /B 0 
)

If you want to use it as a scheduled task, you can change the line SET SvcName=Servicename to SET SvcName=%~1, you then can start it as check-service.cmd "ServiceName".

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