LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-14-2003, 11:17 AM   #1
fishsponge
Member
 
Registered: Apr 2003
Location: Cambridge, UK
Distribution: Debian/Solaris
Posts: 147

Rep: Reputation: 15
Question HELP!! Restricting CPU Usage??


I have a debian machine at home, and i have given someone an account on there, to do whatever they like with.

However, i would like to restrict them to only have the ability to use 25% of my CPU. They can run stuff at whatever priority they like, and as many processes as they like, but as an absolute maximum, they can only occupy 25% of my CPU.

Any ideas??
 
Old 04-14-2003, 11:25 AM   #2
Shak
Member
 
Registered: May 2002
Location: Huddersfield
Distribution: Redhat (7.2, 7.3, 8.0), Debian, Slackware, Gentoo, FreeBSD
Posts: 169

Rep: Reputation: 30
I know you say that you'd like to have anything running at what ever priority the person wants but I'd say that the best way to do this would be to use the nice command to set the priority of the program

man renice and man nice should help, renice has the ability to apply a nice value to a program after it has been launched, so a shell script might come in handy.

We use this on a commercial shell server that we run, we haven't found the best way to restrict to the % of the CPU, I still say even if we did I would choose something like nice because sometimes processes spike to say 30% for a second or two while they do something intense, if the process was limited then maybe it might have problems or something.

Shak
 
Old 04-14-2003, 11:28 AM   #3
fishsponge
Member
 
Registered: Apr 2003
Location: Cambridge, UK
Distribution: Debian/Solaris
Posts: 147

Original Poster
Rep: Reputation: 15
the actual process in question is DNET. This doesn't spike, and even if it did, it shouldn't matter, cos it'd just be like it was running on a CPU that was 25% the speed!

Also... the nice value is useful, but it doesn't restrict a process to a percentage of the CPU... it just sets it's processor scheduling priority. If the machine is completely idle except for dnet, it would still run at about 100%. I want it to run at a maximum of 25%.
 
Old 04-14-2003, 11:36 AM   #4
Shak
Member
 
Registered: May 2002
Location: Huddersfield
Distribution: Redhat (7.2, 7.3, 8.0), Debian, Slackware, Gentoo, FreeBSD
Posts: 169

Rep: Reputation: 30
Ah, totally different context to what I was thinking, when we use processes like that we're usually talking about an IRC bot or something.

Im not sure about dnet, I'd just say don't use it!

Shak
 
Old 04-14-2003, 12:10 PM   #5
fishsponge
Member
 
Registered: Apr 2003
Location: Cambridge, UK
Distribution: Debian/Solaris
Posts: 147

Original Poster
Rep: Reputation: 15
it's not about DNET specifically, it's about any process.... in fact, what i want to do is restrict a particular user to only being able to use 25% of the CPU at any one time.

I'm pretty sure there's a program out there to do this, but i just don't know it's name...
 
Old 04-14-2003, 12:33 PM   #6
cuckoopint
Member
 
Registered: Feb 2003
Distribution: Debian
Posts: 797

Rep: Reputation: 30
there are some things floating around.

some ideas:

man 1 bash
/ulimit

PAM also has some limits. I know it has a process limit, not sure about cpu usage, though.

there's also:
man setrlimit
(but as you can see, its setrlimit(2) and they're just programming functions.)
; )
 
Old 04-14-2003, 12:43 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Maybe this: http://www.tls-technologies.com/CPU/cpu-intro.html
only linux-i386-2.4x tho.
 
Old 04-14-2003, 01:06 PM   #8
cuckoopint
Member
 
Registered: Feb 2003
Distribution: Debian
Posts: 797

Rep: Reputation: 30
In response to unSpawn:

Quote:
Things that may be done if I have spare time or enough encouragement:
Patch for limiting CPU usage for a given process group.
Patch for limiting CPU usage for a given user.
so, we all have ideas that kind of go around it, but not quite there. So for now, I guess you can monitor this users activities and use unSpawn's posted proggy to slow down the really heavy ones.
 
Old 04-15-2003, 03:22 AM   #9
fishsponge
Member
 
Registered: Apr 2003
Location: Cambridge, UK
Distribution: Debian/Solaris
Posts: 147

Original Poster
Rep: Reputation: 15
thanks for all the responses guys!! shame it's something as drastic as a kernel patch, but i should have figured that out anyway!

i might take a look at it when i get time... cheers!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
getting realtime info on memory usage-cpu and harddrive usage steering Linux - Newbie 5 03-03-2005 08:43 PM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM
Controlling CPU usage & memory usage Saravana babu Linux - Software 0 02-18-2004 05:55 AM
Squid - restricting usage by time 7 IP cic Linux - Networking 0 10-28-2002 03:41 AM
Restricting user disk usage ugenn Linux - General 1 05-13-2002 09:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration