[arch-general] renice Bash at login
Hi all, I searched around with no help so if you can help out: I am trying to renice the user bash on Login. So every time someone logs through SSH to the server to get a lower priority than normal. Is that possible? Is it a good idea in general? A server usually is not to be used from users, only login sporadic to do updates and various maintenance work Thanks Leonidas -- Caution: breathing may be hazardous to your health. #include <stdio.h> int main(){printf("%s","\x4c\x65\x6f\x6e\x69\x64\x61\x73");}
[2012-04-23 14:02:23 +0100] Leonidas Spyropoulos:
I am trying to renice the user bash on Login. So every time someone logs through SSH to the server to get a lower priority than normal. Is that possible? Is it a good idea in general?
Why would you want to do that? As root, you can use nicenesses from -20 to -1 to schedule your tasks with higher priority. Nicenesses from 1 to 20 are for users to decrease their tasks' scheduling priority. -- Gaetan
On Mon, Apr 23, 2012 at 2:21 PM, Gaetan Bisson <bisson@archlinux.org> wrote:
[2012-04-23 14:02:23 +0100] Leonidas Spyropoulos:
I am trying to renice the user bash on Login. So every time someone logs through SSH to the server to get a lower priority than normal. Is that possible? Is it a good idea in general?
Why would you want to do that? As root, you can use nicenesses from -20 to -1 to schedule your tasks with higher priority. Nicenesses from 1 to 20 are for users to decrease their tasks' scheduling priority.
Well I want to decrease the priority of all users logged into the system (expect root) at login. So let's say run every bash and every spawned process that a user run with priority 5.
-- Gaetan
-- Caution: breathing may be hazardous to your health. #include <stdio.h> int main(){printf("%s","\x4c\x65\x6f\x6e\x69\x64\x61\x73");}
[2012-04-23 14:25:09 +0100] Leonidas Spyropoulos:
Well I want to decrease the priority of all users logged into the system (expect root) at login. So let's say run every bash and every spawned process that a user run with priority 5.
I understand but why do that when you can just increase the scheduling priority of your beloved root processes instead? -- Gaetan
On Mon, Apr 23, 2012 at 2:30 PM, Gaetan Bisson <bisson@archlinux.org> wrote:
[2012-04-23 14:25:09 +0100] Leonidas Spyropoulos:
Well I want to decrease the priority of all users logged into the system (expect root) at login. So let's say run every bash and every spawned process that a user run with priority 5.
I understand but why do that when you can just increase the scheduling priority of your beloved root processes instead? True effectively it's the same, but still I would like to not be forced to run nice for every command the root run.
-- Gaetan
-- Caution: breathing may be hazardous to your health. #include <stdio.h> int main(){printf("%s","\x4c\x65\x6f\x6e\x69\x64\x61\x73");}
[2012-04-23 14:52:56 +0100] Leonidas Spyropoulos:
True effectively it's the same, but still I would like to not be forced to run nice for every command the root run.
You don't need to do that for *every* command, just those that are super important to you. Anything else sounds like bad practice to me. But see `man limits.conf` if you really want to... -- Gaetan
On Mon, Apr 23, 2012 at 14:25:09 +0100, Leonidas Spyropoulos wrote:
Well I want to decrease the priority of all users logged into the system (expect root) at login. So let's say run every bash and every spawned process that a user run with priority 5.
If your users are just running vi and grep and the like, and not any long-running, CPU intensitive tasks, this will make zero difference in overall performance of your server. Geert -- geert.hendrickx.be :: geert@hendrickx.be :: PGP: 0xC4BB9E9F This e-mail was composed using 100% recycled spam messages!
On 23-04-2012 14:48, Geert Hendrickx wrote:
On Mon, Apr 23, 2012 at 14:25:09 +0100, Leonidas Spyropoulos wrote:
Well I want to decrease the priority of all users logged into the system (expect root) at login. So let's say run every bash and every spawned process that a user run with priority 5.
If your users are just running vi and grep and the like, and not any long-running, CPU intensitive tasks, this will make zero difference in overall performance of your server.
Geert
I've dealt with CPU hogging processes with a cron job. It runs every hour and does the following _only_ for user accounts (it doesn't touch root or system/daemons accounts): for every process check if it has used more than 30min of cpu time, if yes then check niceness, if niceness is lower than 15, raise niceness to 15, otherwise do nothing. Normal processes should not be affected, short spikes of cpu usage are allowed but cpu hogging processes will get niced not to slow the whole system to a halt. The idea is to interfere as little as possible with the running processes. -- Mauro Santos
On Monday, April 23, 2012, Mauro Santos <registo.mailling@gmail.com> wrote:
On 23-04-2012 14:48, Geert Hendrickx wrote:
On Mon, Apr 23, 2012 at 14:25:09 +0100, Leonidas Spyropoulos wrote:
Well I want to decrease the priority of all users logged into the system (expect root) at login. So let's say run every bash and every spawned process that a user run with priority 5.
If your users are just running vi and grep and the like, and not any long-running, CPU intensitive tasks, this will make zero difference in overall performance of your server.
Geert
I've dealt with CPU hogging processes with a cron job. It runs every hour and does the following _only_ for user accounts (it doesn't touch root or system/daemons accounts): for every process check if it has used more than 30min of cpu time, if yes then check niceness, if niceness is lower than 15, raise niceness to 15, otherwise do nothing.
Normal processes should not be affected, short spikes of cpu usage are allowed but cpu hogging processes will get niced not to slow the whole system to a halt. The idea is to interfere as little as possible with the running processes. Can you share the script please?
-- Mauro Santos
-- Caution: breathing may be hazardous to your health. #include <stdio.h> int main(){printf("%s","\x4c\x65\x6f\x6e\x69\x64\x61\x73");}
On 23-04-2012 19:03, Leonidas Spyropoulos wrote:
Can you share the script please?
-- Mauro Santos
For arch it would be something like this: #!/bin/bash renice 15 `ps axo "bsdtime,euid,pid,nice,%cpu,comm" | sed 's/:..//' | awk '{if ($2 >= 1000 && $1 > 30 && $5 > 80 && $4 < 15 ) print $3}'` The script should be only two lines long (the shebang + command). Name it whatever you like, put it inside /etc/cron.hourly and make sure it is executable. I guess it's not pretty but gets the job done :p -- Mauro Santos
On Mon, Apr 23, 2012 at 7:27 PM, Mauro Santos <registo.mailling@gmail.com> wrote:
On 23-04-2012 19:03, Leonidas Spyropoulos wrote:
Can you share the script please?
-- Mauro Santos
For arch it would be something like this:
#!/bin/bash renice 15 `ps axo "bsdtime,euid,pid,nice,%cpu,comm" | sed 's/:..//' | awk '{if ($2 >= 1000 && $1 > 30 && $5 > 80 && $4 < 15 ) print $3}'`
The script should be only two lines long (the shebang + command). Name it whatever you like, put it inside /etc/cron.hourly and make sure it is executable. I guess it's not pretty but gets the job done :p
Thanks that will do probably.
-- Mauro Santos
-- Caution: breathing may be hazardous to your health. #include <stdio.h> int main(){printf("%s","\x4c\x65\x6f\x6e\x69\x64\x61\x73");}
Leonidas Spyropoulos <artafinde@gmail.com> writes:
Hi all,
I searched around with no help so if you can help out:
I am trying to renice the user bash on Login. So every time someone logs through SSH to the server to get a lower priority than normal. Is that possible?
Of course, the simplest being `exec nice 10 bash' in your .bash_profile. renice is not always needed.
Is it a good idea in general? A server usually is not to be used from users, only login sporadic to do updates and various maintenance work
Thanks Leonidas
-- Carl Lei (XeCycle) Department of Physics, Shanghai Jiao Tong University OpenPGP public key: 7795E591 Fingerprint: 1FB6 7F1F D45D F681 C845 27F7 8D71 8EC4 7795 E591
participants (5)
-
Gaetan Bisson
-
Geert Hendrickx
-
Leonidas Spyropoulos
-
Mauro Santos
-
XeCycle