您现在的位置是:主页 > news > 网站新闻置顶怎么做/网站技术制作

网站新闻置顶怎么做/网站技术制作

admin2025/4/22 21:36:01news

简介网站新闻置顶怎么做,网站技术制作,开发一个官方网站要多少钱,一图读懂制作网站思想:利用命令查到内核个数,使用死循环占用每一个内核资源,消耗cpu总资源 前半部分没有作条件表达式判断,有需求的可以自行添加 #! /bin/bash ############################################################# # this scr…

网站新闻置顶怎么做,网站技术制作,开发一个官方网站要多少钱,一图读懂制作网站思想:利用命令查到内核个数,使用死循环占用每一个内核资源,消耗cpu总资源 前半部分没有作条件表达式判断,有需求的可以自行添加 #! /bin/bash ############################################################# # this scr…

 思想:利用命令查到内核个数,使用死循环占用每一个内核资源,消耗cpu总资源

前半部分没有作条件表达式判断,有需求的可以自行添加

#! /bin/bash
#############################################################
#       this scripts for cpu usage testing
#       eg.  cpu_test.sh start  50 #start testing use 50% cpu
#       eg.  cpu_test.sh stop  #stop testing
#############################################################
op=$1
num=$2mkcsp()
{touch ./killcpu.cecho 'int main(){while(1);return 0;}' > killcpu.cgcc -o out killcpu.cchmod +x ./out}start()
{
cpu_num=$(cat /proc/cpuinfo | grep "physical id" | wc -l)for i in `seq 1 $(expr $num \* $cpu_num / 100)`do./out &done}stop()
{
for i in $( ps -ef | grep './out'| grep -v grep | awk '{print $2}')dokill -9 $idone
rm -rf killcpu.c out
}main()
{
if [ $op == "start" ]
thenmkcsp
fi$op
}main

朋友的脚本 ,我师父啊~

#!/bin/bash
# Destription: testing cpu usage performance
# Example    : sh cpu_usage.sh 12
# Remark     : cat /proc/cpuinfo | grep "processor"|wc -l    #12==>Get the number of processor
# Date       : 2015-1-12
# update     : 2015-1-12endless_loop()
{echo -ne "i=0;while truedoi=i+100;i=100done" | /bin/bash &
}if [ $# != 1 ] ; thenecho "USAGE: $0 <CPUs>"exit 1;
fi
for i in `seq $1`
doendless_looppid_array[$i]=$! ;
donefor i in "${pid_array[@]}"; doecho 'kill ' $i ';';
done