简体   繁体   English

如何使用bash获取进程的有效用户名和Schduling类-Linux

[英]How to get Effective User Name and Schduling Class for a process using bash - linux

I'm trying to write a bash script that takes a process ID as the user input and prints out information about that process such as the nice value, priority ...etc. 我正在尝试编写一个bash脚本,该脚本以一个进程ID作为用户输入,并打印出有关该进程的信息,例如nice值,priority等。 I almost got all what I need with help from this site: http://linux.die.net/man/5/proc 我几乎可以从该站点获得所需的一切: http : //linux.die.net/man/5/proc

However, I couldn't find from where I can get the effective user name and the scheduling class of the process. 但是,我无法从哪里获得有效的用户名和流程的调度类

Any help would be appreciated. 任何帮助,将不胜感激。

The negated scheduling priority can be found as the 18th field of /proc/[pid]/stat as detailed in your link. 否定的调度优先级可以在/proc/[pid]/stat的第18个字段中找到,如您的链接中所述。

cat /proc/207/stat | cut -d' ' -f18

As for the owner of the process, it's the owner of the /proc/[pid] directory, or of any file in it. 对于进程的所有者,它是/proc/[pid]目录或其中的任何文件的所有者。

stat -c "%U" /proc/207/

Edit : removed my scheduling priority calculation because I don't know the first thing about it and might misinterpret the documentation. 编辑:删除了我的计划优先级计算,因为我不了解它的第一件事,并且可能会误解文档。 I'll just leave where the negated one can be found. 我将离开找到被否定的地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM