#!/usr/bin/python
# coding=utf-8
importos,sys,time
importlogging
host='114.114.114.114'
logging.basicConfig(level=logging.DEBUG,
    format='%(asctime)-30s%(message)s',
    datefmt='%Y-%m-%d%H:%M:%S',
    filename=host+'.log',
    filemode='a')
aping=os.popen('ping'+host)
whileTrue:
    logging.info(aping.readline().rstrip())

启动直接 nohup python filename > /dev/null & 就可以了,kill的时候注意要kill两个进程,一个python 一个ping

相关文章:

  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
猜你喜欢
  • 2021-04-09
  • 2022-02-15
  • 2021-09-13
  • 2021-08-15
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案