ubuntu cpustat日志保存位置说明
核心结论
常见保存方式与示例
cpustat -p all 1 10 > cpustat_report.txt,日志会生成在你执行命令时所在的目录(这里是当前目录的 cpustat_report.txt)。cpustat -p all 1 10 | tee cpustat_report.txt,便于边看边存。watch -n 1 'cpustat -h 1 >> cpu_load.log',日志会写入当前目录的 cpu_load.log;也可改为绝对路径如 /var/log/cpu_load.log(需有写权限)。0 * * * * /usr/bin/cpustat -u 1 > /var/log/cpustat_hourly.log,将每小时的用户态统计追加到 /var/log/cpustat_hourly.log(需确保目录可写)。易混淆点
快速排查与建议
which cpustat(通常为 /usr/bin/cpustat)。ls -l 查看是否生成了文件(如 cpustat_report.txt、cpu_load.log 等)。sudo touch /var/log/cpustat_test && sudo rm /var/log/cpustat_test 测试,或在 crontab 中使用 sudo crontab -e 以 root 身份写入。