<?php /** * 场景: * 进程监控文件改动 */ date_default_timezone_set('PRC'); echo '进程id:' . posix_getpid() . PHP_EOL; cli_set_process_title('php_c1'); $child = new \Swoole\Process(function () { echo '子进程id:' . posix_getpid() . PHP_EOL; cli_set_process_title('php_c1_child'); $filepath = __DIR__ . DIRECTORY_SEPARATOR . 'a.txt'; $watchMd5 = md5_file($filepath); while (true) { sleep(3); $getMd5 = md5_file($filepath); if (strcmp($watchMd5, $getMd5) !== 0) { echo date('[Y-m-d H:i:s] ') . $filepath . '被修改' . PHP_EOL; $watchMd5 = $getMd5; } } }); $child->start(); //echo $child->read(); \Swoole\Process::wait();
swoole 监控文件改动
猜你喜欢
转载自www.cnblogs.com/cshaptx4869/p/11974354.html
今日推荐
周排行