I recently got a Raspberry Pi 3 to learn linux and explore the world of single board computers. I am running a recent version of Raspbian (not exactly sure which) on it.
After watching some tutorial videos, I decided to explore stress testing the cpu and observing the reported temperatures. The method I chose was to create two bash files: infinite_loop.bash and cpu_spike.bash.
infinite_loop.bash contains an infinite while loop that does some large exponentiation computation. cpu_spike.bash calls the infinite_loop.bash to run on each of the Pi's 4 cores and this script also displays the Pi's reported temperature every 5 seconds for the duration desired. The scripts work fine (causing all cores to go to 100% and produce an observed temperature increase), but one aspect that does not is trying to kill the infinite_loop.bash process at the end of the cpu_spike.bash script!
ps -A
returns that each process name is listed as 'bash' and not 'infinite_loop.bash' or 'infinite_loop' or anything that is recognizable. So in the example code I followed, I cannot have the following the following line at the end of the cpu_spike script:
killall infinite_loop.bash
The command line returns 'infinite_loop.bash' process not found
so, since I saw that each of the infinite loop process was called 'bash' in the running process list, I am using
killall bash
at the end of the test. Is it bad to do this? Why are my infinite loop processes not being called anything that resembles the name of the script?
Please see my original code for cpu_spike.bash below:
#!/bin/bash
#get initial temp
vcgencmd measure_temp
for i in `seq 4` ; do
#put infinite loop on each cpu
/bin/bash /home/pi/infinite_loop.bash &
done
#report temp every 5 seconds for 60 seconds
for value in {1..12}
do
sleep 5s
vcgencmd measure_temp
done
killall bash
Note - I am not sure why the formatting for the two for loops is different. The top loop was the one I got from the example I saw online and the second for loop is my own code from another example I saw.
ps -Af
? Doespkill -f infinite_loop.bash
not work?