How do I set the CPU frequency scaling governor for all cores at once?












32















I'd like to set the CPU frequency scaling governor for all cores at once instead of doing it individually for each core. Is there a way to do this?



(I know it would be easy to echo the governor to /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor, but I'm not looking for a custom solution.)










share|improve this question




















  • 2





    With "custom solution" you mean that a shell script is unacceptable, it needs to be a built-in GUI button?

    – j-g-faustus
    Jan 6 '11 at 16:09













  • I'm just wondering if there already exists a solution in a standard installation (doesn't need to have a GUI).

    – htorque
    Jan 6 '11 at 16:20











  • Check this page: idebian.wordpress.com/2008/06/22/cpu-frequency-scaling-in-linux under "debian implementation": It is apparently possible to change the boot default, and there is a userspace tool called powernowd. (This is a comment rather than reply because the post is from 2008, and I haven't tested if it still works...)

    – j-g-faustus
    Jan 6 '11 at 22:47


















32















I'd like to set the CPU frequency scaling governor for all cores at once instead of doing it individually for each core. Is there a way to do this?



(I know it would be easy to echo the governor to /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor, but I'm not looking for a custom solution.)










share|improve this question




















  • 2





    With "custom solution" you mean that a shell script is unacceptable, it needs to be a built-in GUI button?

    – j-g-faustus
    Jan 6 '11 at 16:09













  • I'm just wondering if there already exists a solution in a standard installation (doesn't need to have a GUI).

    – htorque
    Jan 6 '11 at 16:20











  • Check this page: idebian.wordpress.com/2008/06/22/cpu-frequency-scaling-in-linux under "debian implementation": It is apparently possible to change the boot default, and there is a userspace tool called powernowd. (This is a comment rather than reply because the post is from 2008, and I haven't tested if it still works...)

    – j-g-faustus
    Jan 6 '11 at 22:47
















32












32








32


10






I'd like to set the CPU frequency scaling governor for all cores at once instead of doing it individually for each core. Is there a way to do this?



(I know it would be easy to echo the governor to /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor, but I'm not looking for a custom solution.)










share|improve this question
















I'd like to set the CPU frequency scaling governor for all cores at once instead of doing it individually for each core. Is there a way to do this?



(I know it would be easy to echo the governor to /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor, but I'm not looking for a custom solution.)







cpufreq






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 6 '11 at 8:58







htorque

















asked Jan 6 '11 at 8:53









htorquehtorque

46.9k32172212




46.9k32172212








  • 2





    With "custom solution" you mean that a shell script is unacceptable, it needs to be a built-in GUI button?

    – j-g-faustus
    Jan 6 '11 at 16:09













  • I'm just wondering if there already exists a solution in a standard installation (doesn't need to have a GUI).

    – htorque
    Jan 6 '11 at 16:20











  • Check this page: idebian.wordpress.com/2008/06/22/cpu-frequency-scaling-in-linux under "debian implementation": It is apparently possible to change the boot default, and there is a userspace tool called powernowd. (This is a comment rather than reply because the post is from 2008, and I haven't tested if it still works...)

    – j-g-faustus
    Jan 6 '11 at 22:47
















  • 2





    With "custom solution" you mean that a shell script is unacceptable, it needs to be a built-in GUI button?

    – j-g-faustus
    Jan 6 '11 at 16:09













  • I'm just wondering if there already exists a solution in a standard installation (doesn't need to have a GUI).

    – htorque
    Jan 6 '11 at 16:20











  • Check this page: idebian.wordpress.com/2008/06/22/cpu-frequency-scaling-in-linux under "debian implementation": It is apparently possible to change the boot default, and there is a userspace tool called powernowd. (This is a comment rather than reply because the post is from 2008, and I haven't tested if it still works...)

    – j-g-faustus
    Jan 6 '11 at 22:47










2




2





With "custom solution" you mean that a shell script is unacceptable, it needs to be a built-in GUI button?

– j-g-faustus
Jan 6 '11 at 16:09







With "custom solution" you mean that a shell script is unacceptable, it needs to be a built-in GUI button?

– j-g-faustus
Jan 6 '11 at 16:09















I'm just wondering if there already exists a solution in a standard installation (doesn't need to have a GUI).

– htorque
Jan 6 '11 at 16:20





I'm just wondering if there already exists a solution in a standard installation (doesn't need to have a GUI).

– htorque
Jan 6 '11 at 16:20













Check this page: idebian.wordpress.com/2008/06/22/cpu-frequency-scaling-in-linux under "debian implementation": It is apparently possible to change the boot default, and there is a userspace tool called powernowd. (This is a comment rather than reply because the post is from 2008, and I haven't tested if it still works...)

– j-g-faustus
Jan 6 '11 at 22:47







Check this page: idebian.wordpress.com/2008/06/22/cpu-frequency-scaling-in-linux under "debian implementation": It is apparently possible to change the boot default, and there is a userspace tool called powernowd. (This is a comment rather than reply because the post is from 2008, and I haven't tested if it still works...)

– j-g-faustus
Jan 6 '11 at 22:47












7 Answers
7






active

oldest

votes


















20














I'm still a linux noob but don't you think cpufrequtils lets u do it by using
(its not bundled in the Ubuntu OS but is there in the repository)



sudo apt-get install cpufrequtils
sudo cpufreq-set -r -g performance



  • The -r flag is used to set the change for all ("all hardware related") cores






share|improve this answer





















  • 6





    The -r related option doesn't do it for all the cores. We have to specify the cpu number with option -c <number> however this script will do it for all cpus in one go: for ((i=0;i<$(nproc);i++)); do cpufreq-set -c $i -r -g performance; done

    – Sri
    Sep 11 '14 at 9:50






  • 6





    Exactly, @Sri is right. cpufreq-set in fact lacks of ultimately simple but needed functionality. Lots of people as this vote counters clearly shows are just not aware of it because its description is simply misleading to top it off.

    – poige
    Oct 27 '15 at 16:43






  • 2





    Who gives these +1's without testing???? This does not work at all. I posted the simplest working solution I could find.

    – switch87
    Dec 1 '16 at 12:51



















14














I googled a lot and I think it's just not possible, so I added the following one-liner to my .bashrc:



function setgov ()
{
echo "$1" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
}


Now I can run something like setgov ondemand and all cores will switch to the ondemand governor.






share|improve this answer





















  • 2





    This doesn't work as the file scaling_governor is owned by root and has restricted permissions. Changing the permissions is not always recommended.

    – Sri
    Sep 11 '14 at 9:16











  • Please see alternative script in my comment to user49449's answer.

    – Sri
    Sep 11 '14 at 9:53



















5














the shortest command to change governor of all cores is the following:



sudo bash -c 'for i in {0..7}; do cpufreq-set -c $i -g performance; done'


You could add it to .bashrc like htorque mentioned, you will have to run it as root sudo setgov performance:



function setgov ()
{
for i in {0..7};
do
cpufreq-set -c $i -g $1;
done
}





share|improve this answer

































    2














    Might as well add bash code completion, while we're at it:



    function setgovernor () {
    echo "$1" | sudo tee
    /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
    }
    complete -W "$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)" setgovernor





    share|improve this answer































      1














      The way I set this to stick since the governor defaults back to powersave after about 30 seconds now as of Ubuntu 16.04 or sooner (I'm on Ubuntu Mate);





      1. Put this (one line of) code (thank you, courtesy of switch87 in the previous answer)



        sleep 60 && bash -c 'for i in {0..7}; do cpufreq-set -c $i -g performance; done'



      2. into the file in the directory



        /etc/rc.local



      Mine is a line above "exit 0" and uncommented, under the commented ones.



      "rc.local" for those who do not know, it runs the command as sudo. Any command it seems, to change the governor, needs to be run as sudo.



      It lets the governor reset back to powersave and runs the code as sudo after 60 seconds to change it back to performance.



      Change the "60" (in the code you copy) to whatever time (in seconds. 60 = 60 seconds= 1 minute) you need to delay the command and "performance" (in the command part) to what governor you want it to change to.



      Out of my hours and hours of searching I have not found a more permanent fix for this than this.
      I figure what's a couple of minutes that it's on powersave if this is the best fix I've found, right? Right.



      Not the best fix, but it makes it somewhat permanent after it does it's little switch to powersave thing. If you want to boot right up and jump into a game or something you're going to have to wait a minute for the code you just put in to switch it back from powersave or lower the timing on it (depending on how long it takes everything to start up so it'll switch back to performance correctly).



      And, as always, to revert back to default (I've seen some issues with people's PCs overheating which is why they might have defaulted it to powersave in the first place) just remove the code from rc.local and reboot or switch it back manually with your cpu icon indicator switcher or run;



       sudo /etc/init.d/cpufrequtils restart


      in the terminal and or reboot.






      share|improve this answer































        0














        Basing on switch87's answer, I made a simple script cpufreq-set-all, which will allow to do other cpufreq-set things with all CPUs:



           #!/bin/bash
        MAX_CPU=$((`nproc --all` - 1))
        for i in $(seq 0 $MAX_CPU); do
        echo "Changing CPU " $i " with parameter "$@;
        cpufreq-set -c $i $@ ;
        done


        Now it can be invoked(after chmod +x, of course) like this:



        cpufreq-set-all -g powersave


        or



        cpufreq-set-all -f 800Mhz





        share|improve this answer

































          0














          You can do this for all cores at once by running



          sudo cpupower frequency-set --governor performance





          share|improve this answer








          New contributor




          Martin Andersson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f20271%2fhow-do-i-set-the-cpu-frequency-scaling-governor-for-all-cores-at-once%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            7 Answers
            7






            active

            oldest

            votes








            7 Answers
            7






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            20














            I'm still a linux noob but don't you think cpufrequtils lets u do it by using
            (its not bundled in the Ubuntu OS but is there in the repository)



            sudo apt-get install cpufrequtils
            sudo cpufreq-set -r -g performance



            • The -r flag is used to set the change for all ("all hardware related") cores






            share|improve this answer





















            • 6





              The -r related option doesn't do it for all the cores. We have to specify the cpu number with option -c <number> however this script will do it for all cpus in one go: for ((i=0;i<$(nproc);i++)); do cpufreq-set -c $i -r -g performance; done

              – Sri
              Sep 11 '14 at 9:50






            • 6





              Exactly, @Sri is right. cpufreq-set in fact lacks of ultimately simple but needed functionality. Lots of people as this vote counters clearly shows are just not aware of it because its description is simply misleading to top it off.

              – poige
              Oct 27 '15 at 16:43






            • 2





              Who gives these +1's without testing???? This does not work at all. I posted the simplest working solution I could find.

              – switch87
              Dec 1 '16 at 12:51
















            20














            I'm still a linux noob but don't you think cpufrequtils lets u do it by using
            (its not bundled in the Ubuntu OS but is there in the repository)



            sudo apt-get install cpufrequtils
            sudo cpufreq-set -r -g performance



            • The -r flag is used to set the change for all ("all hardware related") cores






            share|improve this answer





















            • 6





              The -r related option doesn't do it for all the cores. We have to specify the cpu number with option -c <number> however this script will do it for all cpus in one go: for ((i=0;i<$(nproc);i++)); do cpufreq-set -c $i -r -g performance; done

              – Sri
              Sep 11 '14 at 9:50






            • 6





              Exactly, @Sri is right. cpufreq-set in fact lacks of ultimately simple but needed functionality. Lots of people as this vote counters clearly shows are just not aware of it because its description is simply misleading to top it off.

              – poige
              Oct 27 '15 at 16:43






            • 2





              Who gives these +1's without testing???? This does not work at all. I posted the simplest working solution I could find.

              – switch87
              Dec 1 '16 at 12:51














            20












            20








            20







            I'm still a linux noob but don't you think cpufrequtils lets u do it by using
            (its not bundled in the Ubuntu OS but is there in the repository)



            sudo apt-get install cpufrequtils
            sudo cpufreq-set -r -g performance



            • The -r flag is used to set the change for all ("all hardware related") cores






            share|improve this answer















            I'm still a linux noob but don't you think cpufrequtils lets u do it by using
            (its not bundled in the Ubuntu OS but is there in the repository)



            sudo apt-get install cpufrequtils
            sudo cpufreq-set -r -g performance



            • The -r flag is used to set the change for all ("all hardware related") cores







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 4 '17 at 18:49









            Elder Geek

            26.5k952126




            26.5k952126










            answered Mar 6 '12 at 15:13









            user49449user49449

            34124




            34124








            • 6





              The -r related option doesn't do it for all the cores. We have to specify the cpu number with option -c <number> however this script will do it for all cpus in one go: for ((i=0;i<$(nproc);i++)); do cpufreq-set -c $i -r -g performance; done

              – Sri
              Sep 11 '14 at 9:50






            • 6





              Exactly, @Sri is right. cpufreq-set in fact lacks of ultimately simple but needed functionality. Lots of people as this vote counters clearly shows are just not aware of it because its description is simply misleading to top it off.

              – poige
              Oct 27 '15 at 16:43






            • 2





              Who gives these +1's without testing???? This does not work at all. I posted the simplest working solution I could find.

              – switch87
              Dec 1 '16 at 12:51














            • 6





              The -r related option doesn't do it for all the cores. We have to specify the cpu number with option -c <number> however this script will do it for all cpus in one go: for ((i=0;i<$(nproc);i++)); do cpufreq-set -c $i -r -g performance; done

              – Sri
              Sep 11 '14 at 9:50






            • 6





              Exactly, @Sri is right. cpufreq-set in fact lacks of ultimately simple but needed functionality. Lots of people as this vote counters clearly shows are just not aware of it because its description is simply misleading to top it off.

              – poige
              Oct 27 '15 at 16:43






            • 2





              Who gives these +1's without testing???? This does not work at all. I posted the simplest working solution I could find.

              – switch87
              Dec 1 '16 at 12:51








            6




            6





            The -r related option doesn't do it for all the cores. We have to specify the cpu number with option -c <number> however this script will do it for all cpus in one go: for ((i=0;i<$(nproc);i++)); do cpufreq-set -c $i -r -g performance; done

            – Sri
            Sep 11 '14 at 9:50





            The -r related option doesn't do it for all the cores. We have to specify the cpu number with option -c <number> however this script will do it for all cpus in one go: for ((i=0;i<$(nproc);i++)); do cpufreq-set -c $i -r -g performance; done

            – Sri
            Sep 11 '14 at 9:50




            6




            6





            Exactly, @Sri is right. cpufreq-set in fact lacks of ultimately simple but needed functionality. Lots of people as this vote counters clearly shows are just not aware of it because its description is simply misleading to top it off.

            – poige
            Oct 27 '15 at 16:43





            Exactly, @Sri is right. cpufreq-set in fact lacks of ultimately simple but needed functionality. Lots of people as this vote counters clearly shows are just not aware of it because its description is simply misleading to top it off.

            – poige
            Oct 27 '15 at 16:43




            2




            2





            Who gives these +1's without testing???? This does not work at all. I posted the simplest working solution I could find.

            – switch87
            Dec 1 '16 at 12:51





            Who gives these +1's without testing???? This does not work at all. I posted the simplest working solution I could find.

            – switch87
            Dec 1 '16 at 12:51













            14














            I googled a lot and I think it's just not possible, so I added the following one-liner to my .bashrc:



            function setgov ()
            {
            echo "$1" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
            }


            Now I can run something like setgov ondemand and all cores will switch to the ondemand governor.






            share|improve this answer





















            • 2





              This doesn't work as the file scaling_governor is owned by root and has restricted permissions. Changing the permissions is not always recommended.

              – Sri
              Sep 11 '14 at 9:16











            • Please see alternative script in my comment to user49449's answer.

              – Sri
              Sep 11 '14 at 9:53
















            14














            I googled a lot and I think it's just not possible, so I added the following one-liner to my .bashrc:



            function setgov ()
            {
            echo "$1" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
            }


            Now I can run something like setgov ondemand and all cores will switch to the ondemand governor.






            share|improve this answer





















            • 2





              This doesn't work as the file scaling_governor is owned by root and has restricted permissions. Changing the permissions is not always recommended.

              – Sri
              Sep 11 '14 at 9:16











            • Please see alternative script in my comment to user49449's answer.

              – Sri
              Sep 11 '14 at 9:53














            14












            14








            14







            I googled a lot and I think it's just not possible, so I added the following one-liner to my .bashrc:



            function setgov ()
            {
            echo "$1" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
            }


            Now I can run something like setgov ondemand and all cores will switch to the ondemand governor.






            share|improve this answer















            I googled a lot and I think it's just not possible, so I added the following one-liner to my .bashrc:



            function setgov ()
            {
            echo "$1" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
            }


            Now I can run something like setgov ondemand and all cores will switch to the ondemand governor.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 18 '11 at 18:06









            ΤΖΩΤΖΙΟΥ

            74531126




            74531126










            answered Jan 23 '11 at 22:17









            htorquehtorque

            46.9k32172212




            46.9k32172212








            • 2





              This doesn't work as the file scaling_governor is owned by root and has restricted permissions. Changing the permissions is not always recommended.

              – Sri
              Sep 11 '14 at 9:16











            • Please see alternative script in my comment to user49449's answer.

              – Sri
              Sep 11 '14 at 9:53














            • 2





              This doesn't work as the file scaling_governor is owned by root and has restricted permissions. Changing the permissions is not always recommended.

              – Sri
              Sep 11 '14 at 9:16











            • Please see alternative script in my comment to user49449's answer.

              – Sri
              Sep 11 '14 at 9:53








            2




            2





            This doesn't work as the file scaling_governor is owned by root and has restricted permissions. Changing the permissions is not always recommended.

            – Sri
            Sep 11 '14 at 9:16





            This doesn't work as the file scaling_governor is owned by root and has restricted permissions. Changing the permissions is not always recommended.

            – Sri
            Sep 11 '14 at 9:16













            Please see alternative script in my comment to user49449's answer.

            – Sri
            Sep 11 '14 at 9:53





            Please see alternative script in my comment to user49449's answer.

            – Sri
            Sep 11 '14 at 9:53











            5














            the shortest command to change governor of all cores is the following:



            sudo bash -c 'for i in {0..7}; do cpufreq-set -c $i -g performance; done'


            You could add it to .bashrc like htorque mentioned, you will have to run it as root sudo setgov performance:



            function setgov ()
            {
            for i in {0..7};
            do
            cpufreq-set -c $i -g $1;
            done
            }





            share|improve this answer






























              5














              the shortest command to change governor of all cores is the following:



              sudo bash -c 'for i in {0..7}; do cpufreq-set -c $i -g performance; done'


              You could add it to .bashrc like htorque mentioned, you will have to run it as root sudo setgov performance:



              function setgov ()
              {
              for i in {0..7};
              do
              cpufreq-set -c $i -g $1;
              done
              }





              share|improve this answer




























                5












                5








                5







                the shortest command to change governor of all cores is the following:



                sudo bash -c 'for i in {0..7}; do cpufreq-set -c $i -g performance; done'


                You could add it to .bashrc like htorque mentioned, you will have to run it as root sudo setgov performance:



                function setgov ()
                {
                for i in {0..7};
                do
                cpufreq-set -c $i -g $1;
                done
                }





                share|improve this answer















                the shortest command to change governor of all cores is the following:



                sudo bash -c 'for i in {0..7}; do cpufreq-set -c $i -g performance; done'


                You could add it to .bashrc like htorque mentioned, you will have to run it as root sudo setgov performance:



                function setgov ()
                {
                for i in {0..7};
                do
                cpufreq-set -c $i -g $1;
                done
                }






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 1 '16 at 12:53

























                answered Dec 1 '16 at 12:48









                switch87switch87

                15114




                15114























                    2














                    Might as well add bash code completion, while we're at it:



                    function setgovernor () {
                    echo "$1" | sudo tee
                    /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
                    }
                    complete -W "$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)" setgovernor





                    share|improve this answer




























                      2














                      Might as well add bash code completion, while we're at it:



                      function setgovernor () {
                      echo "$1" | sudo tee
                      /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
                      }
                      complete -W "$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)" setgovernor





                      share|improve this answer


























                        2












                        2








                        2







                        Might as well add bash code completion, while we're at it:



                        function setgovernor () {
                        echo "$1" | sudo tee
                        /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
                        }
                        complete -W "$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)" setgovernor





                        share|improve this answer













                        Might as well add bash code completion, while we're at it:



                        function setgovernor () {
                        echo "$1" | sudo tee
                        /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
                        }
                        complete -W "$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)" setgovernor






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jun 5 '18 at 22:03









                        Ray MalangaRay Malanga

                        211




                        211























                            1














                            The way I set this to stick since the governor defaults back to powersave after about 30 seconds now as of Ubuntu 16.04 or sooner (I'm on Ubuntu Mate);





                            1. Put this (one line of) code (thank you, courtesy of switch87 in the previous answer)



                              sleep 60 && bash -c 'for i in {0..7}; do cpufreq-set -c $i -g performance; done'



                            2. into the file in the directory



                              /etc/rc.local



                            Mine is a line above "exit 0" and uncommented, under the commented ones.



                            "rc.local" for those who do not know, it runs the command as sudo. Any command it seems, to change the governor, needs to be run as sudo.



                            It lets the governor reset back to powersave and runs the code as sudo after 60 seconds to change it back to performance.



                            Change the "60" (in the code you copy) to whatever time (in seconds. 60 = 60 seconds= 1 minute) you need to delay the command and "performance" (in the command part) to what governor you want it to change to.



                            Out of my hours and hours of searching I have not found a more permanent fix for this than this.
                            I figure what's a couple of minutes that it's on powersave if this is the best fix I've found, right? Right.



                            Not the best fix, but it makes it somewhat permanent after it does it's little switch to powersave thing. If you want to boot right up and jump into a game or something you're going to have to wait a minute for the code you just put in to switch it back from powersave or lower the timing on it (depending on how long it takes everything to start up so it'll switch back to performance correctly).



                            And, as always, to revert back to default (I've seen some issues with people's PCs overheating which is why they might have defaulted it to powersave in the first place) just remove the code from rc.local and reboot or switch it back manually with your cpu icon indicator switcher or run;



                             sudo /etc/init.d/cpufrequtils restart


                            in the terminal and or reboot.






                            share|improve this answer




























                              1














                              The way I set this to stick since the governor defaults back to powersave after about 30 seconds now as of Ubuntu 16.04 or sooner (I'm on Ubuntu Mate);





                              1. Put this (one line of) code (thank you, courtesy of switch87 in the previous answer)



                                sleep 60 && bash -c 'for i in {0..7}; do cpufreq-set -c $i -g performance; done'



                              2. into the file in the directory



                                /etc/rc.local



                              Mine is a line above "exit 0" and uncommented, under the commented ones.



                              "rc.local" for those who do not know, it runs the command as sudo. Any command it seems, to change the governor, needs to be run as sudo.



                              It lets the governor reset back to powersave and runs the code as sudo after 60 seconds to change it back to performance.



                              Change the "60" (in the code you copy) to whatever time (in seconds. 60 = 60 seconds= 1 minute) you need to delay the command and "performance" (in the command part) to what governor you want it to change to.



                              Out of my hours and hours of searching I have not found a more permanent fix for this than this.
                              I figure what's a couple of minutes that it's on powersave if this is the best fix I've found, right? Right.



                              Not the best fix, but it makes it somewhat permanent after it does it's little switch to powersave thing. If you want to boot right up and jump into a game or something you're going to have to wait a minute for the code you just put in to switch it back from powersave or lower the timing on it (depending on how long it takes everything to start up so it'll switch back to performance correctly).



                              And, as always, to revert back to default (I've seen some issues with people's PCs overheating which is why they might have defaulted it to powersave in the first place) just remove the code from rc.local and reboot or switch it back manually with your cpu icon indicator switcher or run;



                               sudo /etc/init.d/cpufrequtils restart


                              in the terminal and or reboot.






                              share|improve this answer


























                                1












                                1








                                1







                                The way I set this to stick since the governor defaults back to powersave after about 30 seconds now as of Ubuntu 16.04 or sooner (I'm on Ubuntu Mate);





                                1. Put this (one line of) code (thank you, courtesy of switch87 in the previous answer)



                                  sleep 60 && bash -c 'for i in {0..7}; do cpufreq-set -c $i -g performance; done'



                                2. into the file in the directory



                                  /etc/rc.local



                                Mine is a line above "exit 0" and uncommented, under the commented ones.



                                "rc.local" for those who do not know, it runs the command as sudo. Any command it seems, to change the governor, needs to be run as sudo.



                                It lets the governor reset back to powersave and runs the code as sudo after 60 seconds to change it back to performance.



                                Change the "60" (in the code you copy) to whatever time (in seconds. 60 = 60 seconds= 1 minute) you need to delay the command and "performance" (in the command part) to what governor you want it to change to.



                                Out of my hours and hours of searching I have not found a more permanent fix for this than this.
                                I figure what's a couple of minutes that it's on powersave if this is the best fix I've found, right? Right.



                                Not the best fix, but it makes it somewhat permanent after it does it's little switch to powersave thing. If you want to boot right up and jump into a game or something you're going to have to wait a minute for the code you just put in to switch it back from powersave or lower the timing on it (depending on how long it takes everything to start up so it'll switch back to performance correctly).



                                And, as always, to revert back to default (I've seen some issues with people's PCs overheating which is why they might have defaulted it to powersave in the first place) just remove the code from rc.local and reboot or switch it back manually with your cpu icon indicator switcher or run;



                                 sudo /etc/init.d/cpufrequtils restart


                                in the terminal and or reboot.






                                share|improve this answer













                                The way I set this to stick since the governor defaults back to powersave after about 30 seconds now as of Ubuntu 16.04 or sooner (I'm on Ubuntu Mate);





                                1. Put this (one line of) code (thank you, courtesy of switch87 in the previous answer)



                                  sleep 60 && bash -c 'for i in {0..7}; do cpufreq-set -c $i -g performance; done'



                                2. into the file in the directory



                                  /etc/rc.local



                                Mine is a line above "exit 0" and uncommented, under the commented ones.



                                "rc.local" for those who do not know, it runs the command as sudo. Any command it seems, to change the governor, needs to be run as sudo.



                                It lets the governor reset back to powersave and runs the code as sudo after 60 seconds to change it back to performance.



                                Change the "60" (in the code you copy) to whatever time (in seconds. 60 = 60 seconds= 1 minute) you need to delay the command and "performance" (in the command part) to what governor you want it to change to.



                                Out of my hours and hours of searching I have not found a more permanent fix for this than this.
                                I figure what's a couple of minutes that it's on powersave if this is the best fix I've found, right? Right.



                                Not the best fix, but it makes it somewhat permanent after it does it's little switch to powersave thing. If you want to boot right up and jump into a game or something you're going to have to wait a minute for the code you just put in to switch it back from powersave or lower the timing on it (depending on how long it takes everything to start up so it'll switch back to performance correctly).



                                And, as always, to revert back to default (I've seen some issues with people's PCs overheating which is why they might have defaulted it to powersave in the first place) just remove the code from rc.local and reboot or switch it back manually with your cpu icon indicator switcher or run;



                                 sudo /etc/init.d/cpufrequtils restart


                                in the terminal and or reboot.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Apr 13 '18 at 4:35









                                RoiikkaRoiikka

                                262




                                262























                                    0














                                    Basing on switch87's answer, I made a simple script cpufreq-set-all, which will allow to do other cpufreq-set things with all CPUs:



                                       #!/bin/bash
                                    MAX_CPU=$((`nproc --all` - 1))
                                    for i in $(seq 0 $MAX_CPU); do
                                    echo "Changing CPU " $i " with parameter "$@;
                                    cpufreq-set -c $i $@ ;
                                    done


                                    Now it can be invoked(after chmod +x, of course) like this:



                                    cpufreq-set-all -g powersave


                                    or



                                    cpufreq-set-all -f 800Mhz





                                    share|improve this answer






























                                      0














                                      Basing on switch87's answer, I made a simple script cpufreq-set-all, which will allow to do other cpufreq-set things with all CPUs:



                                         #!/bin/bash
                                      MAX_CPU=$((`nproc --all` - 1))
                                      for i in $(seq 0 $MAX_CPU); do
                                      echo "Changing CPU " $i " with parameter "$@;
                                      cpufreq-set -c $i $@ ;
                                      done


                                      Now it can be invoked(after chmod +x, of course) like this:



                                      cpufreq-set-all -g powersave


                                      or



                                      cpufreq-set-all -f 800Mhz





                                      share|improve this answer




























                                        0












                                        0








                                        0







                                        Basing on switch87's answer, I made a simple script cpufreq-set-all, which will allow to do other cpufreq-set things with all CPUs:



                                           #!/bin/bash
                                        MAX_CPU=$((`nproc --all` - 1))
                                        for i in $(seq 0 $MAX_CPU); do
                                        echo "Changing CPU " $i " with parameter "$@;
                                        cpufreq-set -c $i $@ ;
                                        done


                                        Now it can be invoked(after chmod +x, of course) like this:



                                        cpufreq-set-all -g powersave


                                        or



                                        cpufreq-set-all -f 800Mhz





                                        share|improve this answer















                                        Basing on switch87's answer, I made a simple script cpufreq-set-all, which will allow to do other cpufreq-set things with all CPUs:



                                           #!/bin/bash
                                        MAX_CPU=$((`nproc --all` - 1))
                                        for i in $(seq 0 $MAX_CPU); do
                                        echo "Changing CPU " $i " with parameter "$@;
                                        cpufreq-set -c $i $@ ;
                                        done


                                        Now it can be invoked(after chmod +x, of course) like this:



                                        cpufreq-set-all -g powersave


                                        or



                                        cpufreq-set-all -f 800Mhz






                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited Apr 7 '18 at 23:58









                                        Joel Caez

                                        33




                                        33










                                        answered Dec 8 '16 at 11:56









                                        side2kside2k

                                        1011




                                        1011























                                            0














                                            You can do this for all cores at once by running



                                            sudo cpupower frequency-set --governor performance





                                            share|improve this answer








                                            New contributor




                                            Martin Andersson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                            Check out our Code of Conduct.

























                                              0














                                              You can do this for all cores at once by running



                                              sudo cpupower frequency-set --governor performance





                                              share|improve this answer








                                              New contributor




                                              Martin Andersson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                              Check out our Code of Conduct.























                                                0












                                                0








                                                0







                                                You can do this for all cores at once by running



                                                sudo cpupower frequency-set --governor performance





                                                share|improve this answer








                                                New contributor




                                                Martin Andersson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                Check out our Code of Conduct.










                                                You can do this for all cores at once by running



                                                sudo cpupower frequency-set --governor performance






                                                share|improve this answer








                                                New contributor




                                                Martin Andersson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                Check out our Code of Conduct.









                                                share|improve this answer



                                                share|improve this answer






                                                New contributor




                                                Martin Andersson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                Check out our Code of Conduct.









                                                answered Jan 10 at 17:34









                                                Martin AnderssonMartin Andersson

                                                1012




                                                1012




                                                New contributor




                                                Martin Andersson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                Check out our Code of Conduct.





                                                New contributor





                                                Martin Andersson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                Check out our Code of Conduct.






                                                Martin Andersson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                Check out our Code of Conduct.






























                                                    draft saved

                                                    draft discarded




















































                                                    Thanks for contributing an answer to Ask Ubuntu!


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid



                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                    To learn more, see our tips on writing great answers.




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f20271%2fhow-do-i-set-the-cpu-frequency-scaling-governor-for-all-cores-at-once%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    數位音樂下載

                                                    When can things happen in Etherscan, such as the picture below?

                                                    格利澤436b