How can I start a process using cpulimit?
Solution 1
This is unrelated to cpulimit. Running a.out
directly on the command line wouldn't have worked either. When you execute a program without specifying any directory component, the program is looked up in the PATH. The current directory is normally not in the PATH, so you need to give an explicit directory indication.
cpulimit -l 40 -- ./a.out start
It's also generally a good practice to end the options with "--", so cpulimit, or whatever command, won't interpret wrong what comes after that, as an option, when it's part of a file name or an option to a different program.
Solution 2
Right before posting this I decided to try an absolute path and it worked! I decided to post the answer for future Googlers and also to inform that the "start" at the end is not required. This makes it possible to pass arguments to the executable. This is what worked:
cpulimit --limit 40 /home/ben/build/a.out -c 5
Related videos on Youtube
Freedom_Ben
Updated on September 18, 2022Comments
-
Freedom_Ben over 1 year
I am trying to use
cpulimit
for testing an app I'm developing under low resource conditions, and I need the process to start under the influence ofcpulimit
. It is not sufficient to start the program and later applycpulimit
. The example on the cpulimit page does not work for me.The example is this:
cpulimit --limit 40 /etc/rc.d/rc.boinc start
And I'm doing this:
cpulimit --limit 40 a.out start
-
Freedom_Ben almost 11 yearsAh! Just like with GDB. Good insight