Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the simply-static domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/html/wp-includes/functions.php on line 6121
mqtt服务器的软看门狗

mqtt服务器的软看门狗

import os

def getpidinfo():
    p=os.popen('pidof chrome')
    line=p.readline()
    return(line.split())

if __name__ == '__main__':
    if getpidinfo() == []:
        print('none')
    else:
        for i in getpidinfo():
            print(i)

可部署版本

import os
import time
def getpidinfo():
    p=os.popen('pidof mosquitto')
    line=p.readline()
    return(line.split())

if __name__ == '__main__':
    while True:
        if getpidinfo() == []:
           print(getpidinfo())
           os.system('sudo systemctl restart mosquitto.service')
           time.sleep(5)
        else:
           continue