Linux定时收集CPU使用率并将打印到文件
#!/bin/bashwhile [ true ]; do/bin/sleep 3ps auxw|awk '{if (NR>1){print $3}}' > /opt/cpu_listawk '{CPU_PER+=$1}END{print CPU_PER}'/opt/cpu_list | awk '{ print $0"\t" strftime("%H:%M:%S",systime()
·
#!/bin/bash
while [ true ]; do
/bin/sleep 3
ps auxw|awk '{if (NR>1){print $3}}' > /opt/cpu_list
awk '{CPU_PER+=$1}END{print CPU_PER}' /opt/cpu_list | awk '{ print $0"\t" strftime("%H:%M:%S",systime()) } ' >> cpu.txt
done
更多推荐
已为社区贡献2条内容
所有评论(0)