Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hey everyone, I'm not real sure if this is supposed to be in the hardware forum or the software forum. But, I'm having trouble getting cpufreq to keep my settings I put into it. I set both of my cpu's to the 'conservative' governor via the 'sudo cpufreq-set -c 0 -g conservative' and 'sudo cpufreq-set -c 1-g conservative' commands, and it works perfect. But once I restart, both my cpu's go back to the ondemand governor, which I guess is OK, just not what I wanted. Is there a command that I'm not entering that will save my changes to the cpufreq?
This response is a wild-ass guess. Use it only if no one else responds with something more useful, which I hope they do!
First of all, I'm assuming that when you say "restart", you mean "reboot".
I have no use for the cpufreq-set command. I'm guessing from your description, though, that the effects persist only until you reboot. I'm guessing that there's no file or anything where the arguments to the cpufreq-set command are stored or saved.
But that doesn't matter, because there should be some shell scripts on your system which are executed whenever you boot. You can simply insert your commands into one of those shell scripts (using a text editor such as vi or, um, emacs) and you're good to go.
What file should you modify? This will vary from distribution to distribution, and I'm not familiar with Ubuntu. With slackware, for example, a good file to modify would be /etc/rc.d/rc.local. If there's no such file on your Ubuntu system, you'll need either (a) to read appropriate documentation about how Ubuntu systems start up, or (b) wait for someone to come along to this forum who knows the Ubuntu distribution. In the long run, I believe you'll be better off with choice (a).
In any case, if you do change a shell script in this way, you should be keeping a log of _all_ changes you make to your system as root, including the one I recommend. This way, if you ever need to reinstall your system, you won't forget any of these changes.
Of course, you'll want to keep these changes on real paper somewhere, in case the reason you're reinstalling is that the system is dead in the water (unlikely, but the amount of paper required to list your changes should be small).
Oh, ok. I hadn't thought about that. I'm not sure what file to edit though. At first, I thought .bashrc would be the right one, but it only worked if I opened a terminal first. I don't know what the script that executes when you log in is. I found a file called .bash_profile, but it didn't do anything I could tell. Anyone know the right file to edit in Ubuntu? or any other suggestions are very welcome too.
Distribution: The ones that come in magazines and books.
Posts: 136
Rep:
Hey,
I'm not familiar with CPU throttling in Linux, if you could offer an explanation that would be great. Alternately, I can take an educated guess at what it means. If you're trying to set the frequency, what aren't you using BIOS? If it's locked, you might want to try updating it.
Yeah, I'm sorry, I'm trying to set my cpu frequency to automatically go to the 'conservative' governor which lets the processor dynamically step up and down its frequency as needed. I just don't know where to place the commands so they execute when I log in.
Yeah, I'm sorry, I'm trying to set my cpu frequency to automatically go to the 'conservative' governor which lets the processor dynamically step up and down its frequency as needed. I just don't know where to place the commands so they execute when I log in.
".profile", or "/etc/profile" should do the trick for login. Logout, I don't know...
Oh, ok. I hadn't thought about that. I'm not sure what file to edit though. At first, I thought .bashrc would be the right one, but it only worked if I opened a terminal first. I don't know what the script that executes when you log in is. I found a file called .bash_profile, but it didn't do anything I could tell. Anyone know the right file to edit in Ubuntu? or any other suggestions are very welcome too.
You should put those commands in an init script, Debian recently got /etc/rc.local for this purpose, if Ubuntu doesn't have that put it in /etc/rcS.d/S99cpufreq (you will have to create the file).
You should put those commands in an init script, Debian recently got /etc/rc.local for this purpose, if Ubuntu doesn't have that put it in /etc/rcS.d/S99cpufreq (you will have to create the file).
Ok, this is a very noobish question, but how exactly would I go about doing that? I think thats what I've been trying to do, but with extremely little success.
I'm guessing, in agreement with ntubski's post above, that you don't want to do this every time you log in. You probably want to do it once, automatically, each time you boot.
Assuming that this is the case:
You know the basics, right?
The cd command?
How to use a text editor such as vi or emacs?
Ok. From there, it's all a matter of finding the right init script to modify. Init scripts are all kept in one directory. They govern what the system does upon booting and shutting down and similar state transitions.
The problem is that the init scripts are kept in different places for different distributions of Linux.
lcaley, since you use Ubuntu, you should really get familiar with www.ubuntu.com. I have just browsed there for you. You'll find everything you want to know about ubuntu init scripts at
Ok, so the page from ubuntu.com said I should copy my script into /etc/init.d and make it executable. I'm fine with that part, but it skipped the part I don't know how to do. I'm not real sure how to write a script to do this. I wrote what I thought was right and followed the instructions on that page, but it didn't work when I booted. Here's what is in the script right now, I really had very little idea what I was doing when I wrote it, so any "Scripting 101" info will be greatly appreciated.
I think you shouldn't exit in an init script, since that might exit from the whole init process. But in general if you do use exit change exit(0) to exit 0
I changed the script, and it still doesn't work. This is getting ridiculous. It's just a script... does it have something to do with the sudo? The command needs root privileges, but I don't know if it is having a problem with the password or not. Here is the current contents of the script:
The script is located in the /etc/init.d directory, is executable (-rwxr-xr-x), and is linked:
(lcaley@lcaley-laptop:/etc/init.d$ sudo update-rc.d cpufrequencyset.sh start 51 S .
System startup links for /etc/init.d/cpufrequencyset.sh already exist.)
It doesn't give any errors and it doesn't do anything out of the ordinary when I boot or log in. I just simply doesn't work.
So what is still wrong? All I need this thing to do is execute these two commands when I log in.
Never mind, I got it. I changed the script to execute at runlevel 2 instead of at "S" which is what the ubuntu.com site said to do. Thanks for all the help everyone!
The only other thing you might want to consider is removing the "sudo" from that script and see whether it still works. It should. The reason to remove the "sudo" is the general principal that if you can simplify, you should.
More particularly, there's the general principal that each of us becomes a "different person" after, oh, about six months. (Less time than that if you're an old geezer like me.) That is, you will become a stranger to the code or scripts you wrote six months ago or more. It's a memory issue: not computer memory, but your memory. If you look at that script six months from now, you may understand why it worked, but won't understand why you put the "sudo" in there, because you'll understand that init scripts always run as root anyway. And you'll scratch your head and say, "Now I _know_ there's a reason I put that sudo in there", even though there is no reason, and you may waste time and energy pursuing it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.