how to write a script to let cpu busy?

how to write a script to let cpu busy?
and how to write a script to let memory/disk busy?

This gets close :slight_smile:

dd if=/dev/urandom of=/dev/null &
dd if=/dev/urandom of=/dev/null &
dd if=/dev/urandom of=/dev/null &
(repeat for as many CPUs as you have)

nmon output:

x CPU-Utilisation-Small-View x
x                           0----------25-----------50----------75----------100                                                                             x
xCPU User%  Sys% Wait% Idle%|           |            |           |            |                                                                             x
x  0   2.5  76.5   0.0  21.0|Ussssssssssssssssssssssssssssssssssssss>         |                                                                             x
x  1   1.0  80.5   0.0  18.5|ssssssssssssssssssssssssssssssssssssssss         >                                                                             x
x  2   1.0  82.5   0.0  16.5|sssssssssssssssssssssssssssssssssssssssss  >     |                                                                             x
x  3   0.0  87.5   0.0  12.5|sssssssssssssssssssssssssssssssssssssssssss  >   |                                                                             x
xPhysical Averages          +-----------|------------|-----------|------------+                                                                             x
xAll   5.5  74.2   0.0  20.2|>Usssssssssssssssssssssssssssssssssssss          |                                                                             x
x                           +-----------|------------|-----------|------------+

Thank you! Very helpful.

How to do it on memory and disk I/O?

Well, I suppose you could try some of the "SPEC" tests, some of which are designed to measure maximum throughputs. (Others are designed to emulate typical business workloads.)

See: SPEC - Standard Performance Evaluation Corporation

Hi,

try if nstress is doing what you like to do ?

IBM developerWorks: Wikis - AIX - nstress

Kind regards
zxmaus

you could use something like that:
spawns 2 bc processes per processor

#!/usr/bin/ksh
CPUCOUNT=$(($(lsdev -C | grep "[P]rocessor"| wc -l)*2))


while true
        do
                if [ $(ps -ef | grep -w "[d]c" | wc -l ) -lt $CPUCOUNT ]
                      then
                                ps -ef | grep -w "[d]c" | wc -l
                                echo 9999^9999 | bc >/dev/null 2>&1 &
                      fi
        done