利用screen做php的守护进程
2012年2月20日
评论已被关闭
最近一个项目用了页面刷新触发伪cron查询数据库的功能,当流量很大时,需要不停的查,不太好,写了个php脚本,作为进程来运行。
[root@eric home]# screen
运行php脚本
[root@eric home]# php /opt/www/webroot/deal.php
deal.php页为
1 2 3 4 5 6 | while(true){ /* 略 */ sleep(30); } |
ctrl+a +d
OK ,screen -ls 会发现
There are screens on:
28395.pts-4.eric (Detached)
1 Sockets in /var/run/screen/S-root.
关掉 SSH 也可以不停运行了。
想要结束很简单 kill掉 就可以.
Recent Comments