<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Script to hog CPU in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118413#M92859</link>
    <description>10 point to all for being so friggin' fast.&lt;BR /&gt;&lt;BR /&gt;Thank you !  I used the while loop because it was basically what I 1st attempted but the ":" made the difference.</description>
    <pubDate>Tue, 18 Dec 2007 19:26:38 GMT</pubDate>
    <dc:creator>Mike Boswell_1</dc:creator>
    <dc:date>2007-12-18T19:26:38Z</dc:date>
    <item>
      <title>Script to hog CPU</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118409#M92855</link>
      <description>I want to fully utilize a single CPU to testing.  Does anyone have a script of command that I can run that will fully utilize a single CPU for longer than 15 minutes w/ the same PID?  &lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Mike</description>
      <pubDate>Tue, 18 Dec 2007 19:05:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118409#M92855</guid>
      <dc:creator>Mike Boswell_1</dc:creator>
      <dc:date>2007-12-18T19:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Script to hog CPU</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118410#M92856</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;An inadvisable method like try to gzip very very big file with mpsched like&lt;BR /&gt;&lt;BR /&gt;#mpsched -c 1 gzip veryBigFile &lt;BR /&gt;&lt;BR /&gt;1 --&amp;gt; is CPU1, other CPU's will be idle&lt;BR /&gt;&lt;BR /&gt;Best Regards&lt;BR /&gt;Murat Suluhan</description>
      <pubDate>Tue, 18 Dec 2007 19:14:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118410#M92856</guid>
      <dc:creator>Murat SULUHAN</dc:creator>
      <dc:date>2007-12-18T19:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Script to hog CPU</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118411#M92857</link>
      <description>Hi Mike:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;:&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;...this will run endlessly until killed.  The colon ":" is a syntatically correct null statement.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 18 Dec 2007 19:15:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118411#M92857</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-12-18T19:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Script to hog CPU</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118412#M92858</link>
      <description>Hi (again) Mike:&lt;BR /&gt;&lt;BR /&gt;To add, if you want to run for a proscribed period of time, and have the process self-terminate, you can do:&lt;BR /&gt;&lt;BR /&gt;# perl -e '$t=shift||60;$SIG{ALRM}=sub {exit};alarm $t;1 while {}'&lt;BR /&gt;&lt;BR /&gt;By default this will run for 60-seconds.  Pass any number of seconds as an argument to run shorter or longer before self-destructing.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 18 Dec 2007 19:21:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118412#M92858</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-12-18T19:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Script to hog CPU</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118413#M92859</link>
      <description>10 point to all for being so friggin' fast.&lt;BR /&gt;&lt;BR /&gt;Thank you !  I used the while loop because it was basically what I 1st attempted but the ":" made the difference.</description>
      <pubDate>Tue, 18 Dec 2007 19:26:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118413#M92859</guid>
      <dc:creator>Mike Boswell_1</dc:creator>
      <dc:date>2007-12-18T19:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Script to hog CPU</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118414#M92860</link>
      <description>&lt;!--!*#--&gt;Using the shell loop as a process, this script will schedule multiple CPU hogs, wait until terminated and then automatically kill all of them. You can saturate any size system. Note that like most Unix systems, a fully saturated system still responds very fast. Programs that do nothing but compute degrade to the worst priority so that all I/O (disk, tape, keyboard, etc) will still be processed. By using this scheduler, you can create very high load factors (runqueues).&lt;BR /&gt; &lt;BR /&gt;The cpu-bound script is the same as the one James showed:&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;while :&lt;BR /&gt;do&lt;BR /&gt;:&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;Call the above script: cpu-bound&lt;BR /&gt; &lt;BR /&gt;The script below will schedule up to 128 copies of cpu-bound. Just use CTRL-C to terminate the multi-cpu script and all the children will terminate.&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;# multi-cpubound&lt;BR /&gt;&lt;BR /&gt;#   Usage: multi-cpubound 10 script/prog_name [ "param(s)" [ nice or toggle ] ]&lt;BR /&gt;&lt;BR /&gt;# Run a process or script multiple times with optional 50:50 nice&lt;BR /&gt;# Terminate multi-start to terminate all child processes&lt;BR /&gt;&lt;BR /&gt;set -u&lt;BR /&gt;export PATH=/usr/bin&lt;BR /&gt;MYNAME=${0##*/}&lt;BR /&gt;SANEQTY=128&lt;BR /&gt;&lt;BR /&gt;#   F U N C T I O N S &lt;BR /&gt;&lt;BR /&gt;function Usage&lt;BR /&gt;{&lt;BR /&gt;   [ $# -gt 0 ] &amp;amp;&amp;amp; echo "\n$@"&lt;BR /&gt;   cat &amp;lt;&amp;lt; EOF&lt;BR /&gt;&lt;BR /&gt;   Usage: $MYNAME QTY &lt;NICE&gt; PROGNAME [ PROG_PARMS ]&lt;BR /&gt;     where QTY=1 to $SANEQTY,&lt;BR /&gt;           normal = all copies std priority&lt;BR /&gt;           nice = all copies=nice,&lt;BR /&gt;           toggle to alternate each copy&lt;BR /&gt;           PROGNAME is program or script name&lt;BR /&gt;           PARMS = program parameters or ""&lt;BR /&gt;&lt;BR /&gt;EOF&lt;BR /&gt;   exit 1&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;#   M A I N   P R O G R A M&lt;BR /&gt;&lt;BR /&gt;# parameter handling/checking&lt;BR /&gt;&lt;BR /&gt;[ $# -lt 3 ] &amp;amp;&amp;amp; Usage "Requires 3 or more parameters"&lt;BR /&gt;QTY=$1&lt;BR /&gt;&lt;BR /&gt;[ $QTY -lt 1 ] &amp;amp;&amp;amp; QTY=1&lt;BR /&gt;[ $QTY -gt $SANEQTY ] &amp;amp;&amp;amp; QTY=$SANEQTY&lt;BR /&gt;&lt;BR /&gt;# find out the path used to start this prog&lt;BR /&gt;# if the PROGNAME has no directory path, &lt;BR /&gt;#    use this program's path.&lt;BR /&gt;&lt;BR /&gt;MYPATH=$(dirname $0)&lt;BR /&gt;PROGNAME="$MYPATH/$3"&lt;BR /&gt;&lt;BR /&gt;if [ ! -x $PROGNAME ] &lt;BR /&gt;then&lt;BR /&gt;  echo "\n$MYNAME: prog/script \"$PROGNAME\" not found\n"&lt;BR /&gt;  exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;# If parm#2 = normal, all procs=std pri&lt;BR /&gt;# If parm#2 = nice, all procs=nice&lt;BR /&gt;# If parm#2 = toggle, alternate procs start at nice&lt;BR /&gt;&lt;BR /&gt;case $2 in&lt;BR /&gt;     nice ) NICE=true &lt;BR /&gt;            TOGGLE=false&lt;BR /&gt;            ;;&lt;BR /&gt;   toggle ) NICE=false &lt;BR /&gt;            TOGGLE=true&lt;BR /&gt;            ;;&lt;BR /&gt;   normal ) NICE=false&lt;BR /&gt;            TOGGLE=false&lt;BR /&gt;            ;;&lt;BR /&gt;        * ) Usage "Requires 1 of: normal nice toggle"&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;[ $# -gt 3 ] &amp;amp;&amp;amp; PARMS="$@" || PARMS=""&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;COPY=0&lt;BR /&gt;NICE=false&lt;BR /&gt;&lt;BR /&gt;# start the processes&lt;BR /&gt;&lt;BR /&gt;echo "\nStarting $QTY copies of $PROGNAME $PARMS"&lt;BR /&gt;echo "$MYNAME PID = $$, NICE=$NICE toggle=$TOGGLE"&lt;BR /&gt;&lt;BR /&gt;while [ $COPY -lt $QTY ]&lt;BR /&gt;do&lt;BR /&gt;   let COPY=$COPY+1&lt;BR /&gt;   if $TOGGLE&lt;BR /&gt;   then&lt;BR /&gt;     if [ $NICE = true ]&lt;BR /&gt;     then&lt;BR /&gt;        ./$PROGNAME "$PARMS" &amp;amp;&lt;BR /&gt;        NICE=false&lt;BR /&gt;     else&lt;BR /&gt;        nice ./$PROGNAME "$PARMS" &amp;amp;&lt;BR /&gt;        NICE=true&lt;BR /&gt;     fi&lt;BR /&gt;   else&lt;BR /&gt;      ./$PROGNAME "$PARMS" &amp;amp;&lt;BR /&gt;   fi&lt;BR /&gt;   PIDS[$COPY]=$!&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;echo "Child PIDs = ${PIDS[@]}"&lt;BR /&gt;echo&lt;BR /&gt;trap 'echo "trap detected, stopping ${PIDS[@]}";kill ${PIDS[@]};exit' 1 2 3 15&lt;BR /&gt;&lt;BR /&gt;# do nothing forever until terminated&lt;BR /&gt;while :&lt;BR /&gt;do&lt;BR /&gt;  sleep 100&lt;BR /&gt;done&lt;/NICE&gt;</description>
      <pubDate>Wed, 19 Dec 2007 03:30:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-to-hog-cpu/m-p/4118414#M92860</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2007-12-19T03:30:49Z</dc:date>
    </item>
  </channel>
</rss>

