<?php $process = new \Swoole\Process(function(){ $filename = "a.conf"; $md5file = md5_file($filename); while(true){ $newMd5 = md5_file($filename); if(strcmp($md5file,$newMd5) !== 0){ echo "old".$md5file.PHP_EOL; echo 'new'.$newMd5.PHP_EOL; echo "文件被修改了".date("Y-m-d H:i:s").PHP_EOL; $md5file = $newMd5; } } }); $process->start(); $process::wait();