直接上脚本:
#!/bin/bash
while true
do
echo 2^2^20 | bc & >/dev/null
done
查看CPU使用率用top命令即可
释放CPU:
ps -ef |grep bc |grep -v grep |awk '{print $2}' |xargs kill
定时运行Crontab:
*/6 * * * * /bin/bash /home/shells/cpuplus.sh
*/5 * * * * ps -ef |grep cpuplus |grep -v grep |awk '{print $2}' |xargs kill
*/5 * * * * ps -ef |grep bc |grep -v grep |awk '{print $2}' |xargs kill