[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to limit a CPU temperature?



On 4/8/23 07:17, songbird wrote:
   i have a program that has changed it's behavior to suddenly
become a CPU hog (while doing something simple like uploading
files for my website).  probably a bug, but it got me to
wondering how i could limit the CPU temperature to a range
well below the maximum that kicks in by the CPU itself.

   i have an intel processor and it has the MAX which does
prevent it from going higher (100C), but i'd like to keep it
at 70C or lower.

   i've been trying to find anything that will let me set this
but no luck yet in my searches.

   thanks!  :)


   songbird


I previous posted some Perl one-liners to load one processor core for thermal testing:

https://lists.debian.org/debian-user/2021/08/msg01346.html


Here is an updated Perl script that will exercise all cores to a given percentage for a given duration:

2023-04-09 19:06:43 dpchrist@taz ~
$ cat /usr/local/bin/exercise-cpu
#!/usr/bin/env perl
# $Id: exercise-cpu,v 1.1 2023/04/10 02:05:22 dpchrist Exp $
# by David Paul Christensen dpchrist@holgerdanske.com
# Public Domain
#
# Exercise central processing unit

use threads;
use strict;
use warnings;

use File::Basename;
use Time::HiRes qw( sleep time );

die sprintf "Usage: %s PERCENT DURATION\n", basename($0)
    unless @ARGV == 2;

my  $a	= 0.01 * shift;		# periodic exercise duration
my  $b	= 1 - $a;		# periodic sleep duration

$_	= qx/lscpu/;		# Debian GNU/Linux
my ($c)	= /CPU.s.:\s+(\d+)/;	# number of virtual cores

my  $e	= time + shift;		# time to end

my @thr;			# threads

push @thr, async {
    while (time < $e) {
	my $d = time + $a / 10;
	1 while time < $d;
	sleep $b/10;
    }
} for 1..$c;

$_->join for @thr;

2023-04-09 19:06:49 dpchrist@taz ~
$ exercise-cpu 50 10


David


Reply to: