A quick renice command rescheduled the upgrade to a lower priority and I was back to surfing in no time.
https://www.nixtutor.com/linux/changing-priority-on-linux-processes/
Changing Priority on Linux Processes
Wed, Apr 22, 2009
What is Priority and Why Should I Care?
When talking about processes priority is all about managing processor time. The Processor or CPU is like a human juggling multiple tasks at the same time. Sometimes we can have enough room to take on multiple projects. Sometimes we can only focus on one thing at a time. Other times something important pops up and we want to devote all of our energy into solving that problem while putting less important tasks on the back burner.
In Linux we can set guidelines for the CPU to follow when it is looking at all the tasks it has to do. These guidelines are called niceness or nice value. The Linux niceness scale goes from -20 to 19. The lower the number the more priority that task gets. If the niceness value is high number like 19 the task will be set to the lowest priority and the CPU will process it whenever it gets a chance. The default nice value is zero.
By using this scale we can allocate our CPU resources more appropriately. Lower priority programs that are not important can be set to a higher nice value, while high priority programs like daemons and services can be set to receive more of the CPU’s focus. You can even give a specific user a lower nice value for all of his/her processes so you can limit their ability to slow down the computer’s core services.
Checking the Priority of Running Processes
The easiest way to get a quick picture of what the current niceness priority on a process is to open up the top processes with:
top
top
q
h
ps -o pid,comm,nice -p
Setting priority on new processes
At this point you are probably wondering how you can set your own priority levels on processes. To change the priority when issuing a new command you do nice -n [nice value] [command]:
nice -n 10 apt-get upgrade
This will increment the default nice value by a positive 10 for the command, ‘apt-get upgrade’ This is often useful for times when you want to upgrade apps but don’t want the extra process burden at the given time. Remember a positive number is gives less priority for a process.
renice 10 -p 21827
This will increment the priority of the process with an id of 21827 to 10.
Note: Only root can apply negative nice values.
Setting Priority on Existing Processes
Obviously at some point you are going to want to alter the nice value of something that is already running. Just the other day I was doing an upgrade to Ubuntu Jaunty and Firefox started to become unusably slow. A quick renice command rescheduled the upgrade to a lower priority and I was back to surfing in no time.
To change the priority of an existing process just do renice [nice value] -p [process id]:
renice 10 -p 21827
This will increment the priority of the process with an id of 21827 to 10.
Note: Only root can apply negative nice values.
Setting Permanent Priority on all Processes for a Specific User
Sometimes it is helpful to give specific users lower priority than others to keep system resources allocated in the proper places like core services and other programs.
You can set the default nice value of a particular user or group in the /etc/security/limits.conf file.
/etc/security/limits.conf
It uses this syntax: [username] [hard|soft] priority [nice value]
backupuser hard priority 1
Fields Management for window :Def, whose current sort field is %CPU
Navigate with Up/Dn, Right selects for move then <Enter> or Left commits,
'd' or <Space> toggles display, 's' sets sort. Use 'q' or <Esc> to end! * PID = Process Id
* USER = Effective User Name
* PR = Priority
* NI = Nice Value
* VIRT = Virtual Image (KiB)
* RES = Resident Size (KiB)
* SHR = Shared Memory (KiB)
* S = Process Status
* %CPU = CPU Usage
* %MEM = Memory Usage (RES)
* TIME+ = CPU Time, hundredths
* COMMAND = Command Name/Line
PPID = Parent Process pid
UID = Effective User Id
RUID = Real User Id
RUSER = Real User Name
SUID = Saved User Id
SUSER = Saved User Name
GID = Group Id
GROUP = Group Name
PGRP = Process Group Id
TTY = Controlling Tty
TPGID = Tty Process Grp Id
SID = Session Id
nTH = Number of Threads
P = Last Used Cpu (SMP)
TIME = CPU Time
SWAP = Swapped Size (KiB)
CODE = Code Size (KiB)
DATA = Data+Stack (KiB)
nMaj = Major Page Faults
nMin = Minor Page Faults
nDRT = Dirty Pages Count
WCHAN = Sleeping in Function
Flags = Task Flags <sched.h>
CGROUPS = Control Groups
SUPGIDS = Supp Groups IDs
SUPGRPS = Supp Groups Names
TGID = Thread Group Id
ENVIRON = Environment vars
vMj = Major Faults delta
vMn = Minor Faults delta
USED = Res+Swap Size (KiB)
nsIPC = IPC namespace Inode
nsMNT = MNT namespace Inode
nsNET = NET namespace Inode
nsPID = PID namespace Inode
nsUSER = USER namespace Inode
nsUTS = UTS namespace Inode
A quick renice command rescheduled the upgrade to a lower priority and I was back to surfing in no time.的更多相关文章
- Visual Studio 调试技巧[Command Window & Immediate Window ](Tips)
Visual Studio 调试技巧[Command Window & Immediate Window ](Tips) 1. immediate window 定义的一些 alias (// ...
- Rocket - debug - Example: Quick Access
https://mp.weixin.qq.com/s/SxmX-CY2tqvEqZuAg-EXiQ 介绍riscv-debug的使用实例:配置Quick Access功能. 1. Quick Acce ...
- linux 操作
正在运行的内核和系统信息 # uname -a # 获取内核版本(和BSD版本) # lsb_release -a # 显示任何 LSB 发行版版本信息 # cat /etc/SuSE-release ...
- linux分析、诊断及调优的必备“杀器”之一
下面分别列出linux分析.诊断及调优时用到的工具,并分别进行说明,以方便自己和其他同学参考学习,禁止转载. 1.top top - 02:06:59 up 4 days, 17:14, 2 user ...
- Spring Boot Reference Guide
Spring Boot Reference Guide Authors Phillip Webb, Dave Syer, Josh Long, Stéphane Nicoll, Rob Winch, ...
- yum 工作原理
MySQL :: A Quick Guide to Using the MySQL Yum Repository https://dev.mysql.com/doc/mysql-yum-repo-qu ...
- Performance Tuning Using Linux Process Management Commands
[root@bigdata-server-02 /]# ps --help all Usage: ps [options] Basic options: -A, -e all processes -a ...
- linux应用之mysql数据库指定版本的yum安装(centos)
A Quick Guide to Using the MySQL Yum Repository Abstract The MySQL Yum repository provides RPM packa ...
- MySQL/MariaDB数据库的服务器配置
MySQL/MariaDB数据库的服务器配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.MySQL中的系统数据库 1>.mysql数据库 是mysql的核心数据库,类 ...
随机推荐
- maven工程下 读取resource下配置文件
http://blog.csdn.net/xu511739113/article/details/52440982
- java基础-数组
浏览以下内容前,请点击并阅读 声明 定义:数组是一个能容纳固定数量,类型单一的若干个值的容器.注意,数组是一个对象. 数组一旦创建,则其长度固定不变,数组中的所有值叫元素(Element),获取元素要 ...
- aspx与ashx
ashx在VS的中文版是新建“一般处理程序”,其实是一个实现类System.Web.IHttpHandler接口的类.而任何一个实现了IHttpHandler接口的类都能作为一个外部请求的目标程序.H ...
- 编程思想┊从实例谈面向对象编程(OOP)、工厂模式和重构
有了翅膀才能飞,欠缺灵活的代码就象冻坏了翅膀的鸟儿.不能飞翔,就少了几许灵动的气韵.我们需要给代码带去温暖的阳光,让僵冷的翅膀重新飞起来.结合实例,通过应用OOP.设计模式和重构,你会看到代码是怎样一 ...
- BZOJ3615 : MSS
将所有点按横坐标排序,那么最长上升子序列和最长下降子序列里必有一个长度不小于$\sqrt{n}$. 因为如果最长上升子序列很短,那么根据Dilworth定理,它的反链长度与它成反比. 因此可以将$n$ ...
- ACM 懒省事的小明
懒省事的小明 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 小明很想吃果子,正好果园果子熟了.在果园里,小明已经将所有的果子打了下来,而且按果子的不同种 ...
- 关于scrollbar-face-color只支持ie的解决办法!
关于scrollbar-face-color只支持ie的解决方法!!今天突然有人问我滚动条css自定义的方法,我发现用scrollbar-base-color这种方法只有ie支持,查了半天资料总结如下 ...
- jquery 动画效果插件
从jQuery API 文档中可以知道,jQuery自定义动画的函数.animate( properties [, duration] [, easing] [, complete] )有四个参数: ...
- 移动端touch模块
在自己写touch事件时,总是会出现各种各样的bug,正好发现zepto的touch模块,很好用,而且由于zepto和jquery语法的相似性,这个模块也可以直接引用到jquery中, 得花时间好好消 ...
- BZOJ4532: [BeiJing2014 WinterCamp] 珠链
Description Alex喜欢玩网络游戏,认为这是智力和体力的综合锻炼.在一次游戏活动中,他意外获得了一个传说中威力极其强大的法宝:珠链. 珠链,顾名思义,就是由许多小珠子串起来的一条链.珠子 ...