Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 shell 脚本的初学者,我正在寻找一个脚本来添加为 cron 作业,该作业可以发送电子邮件或使用 top 命令的 CPU 百分比警告电子邮件 ID。
这个脚本基本上是为了让用户注意服务器的峰值 CPU 使用率。如果有任何脚本可以执行此操作或更好地监控 CPU 使用率/内存使用情况,请指出我。
谢谢,阿比
Depending on where your mail is in your linux flavor, you can try
mail
*/10 * * * * /bin/ps -eo pcpu,pid,user,args | /bin/sort -k 1 -r | /bin/mail youremail@where.com
This will send you, every 10 minutes, the cpu usage sorted from the highest to the lowest.