10-2节笔记-监听服务
- 关键函数或者linux命令
- 每隔$time秒执行一次该方法 粒度为毫秒级
swoole_timer_tick($time,function(\$timer_id){})
- (都用绝对路径) 把脚本结果都打印到txt文件中做为日志记录
nohup php server.php > a.txt
- 能把查看的端口信息简化到1或者0返回给我们
php netstat -anp 2>dev/null | grep 8811 | LISTEN | wc -l
shell_exec($shell)
- 例如每隔2秒执行一次该方法:
swoole_timer_tick(2000,function($timer_id){
echo 'success';
})
- 查看端口是否开启
$shell = 'netstat -anp | grep 8811';
- 升级版
$shell = 'netstat -anp | grep 8811 | grep LISTEN | wc -l'
- 最终版
$shell = 'netstat -anp 2>dev/null | grep 8811 | LISTEN | wc -l';