脚本非常简单,不清楚原理,逐行运行即可。
使用时将脚本复制到home目录,并添加执行权限、定时任务即可。
代码内容如下:
#!/bin/sh
date >> /home/date-time.txt
sed 's/$/& Apache complicating No./g' /home/date-time.txt > /home/date-time2.txt
echo | netstat -na | grep ESTABLISHED | wc -l > /home/Connection-No.txt
paste /home/date-time2.txt /home/Connection-No.txt >>/home/Connections.txt
rm -rf /home/date-time.txt
rm -rf /home/date-time2.txt
rm -rf /home/Connection-No.txt # */ * * * * /bin/bash /home/connection.sh