One of my least favorite activities as a support engineer was trying to sift through the debris pile that is the ps
command. Inevitably, a Java process would error out and get stuck on a port that I needed open to restart a service. The service would show as up, but there was no functionality. This situation was confusing to junior techs and was something that I was asked to correct many, many times by finding the process that was stuck and killing it. There are also times where you may need to see if a particular process is running or find out if a process has spawned child processes. These scenarios are where understanding control groups will help tremendously. Control groups, at a basic level, organize processes based on the parent and then organize processes into a hierarchy.
Here, we will look at two ways to improve on the standard ps
command that most people use. I know many people pair ps
with grep
, and like pecan pie and Noah's Mill, I fully endorse this practice. I also encourage you to check into the following two methods, as they can make understanding process hierarchies a bit easier.
Method one
The first method is a standard ps
command with the process tree enabled. When you run this command:
[root@fed31 ~]# ps xawf -eo pid,user,cgroup,args
the following output might be the result:
![ps process output](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2019-12/Screen%20Shot%202019-12-05%20at%2011.55.26%20AM.png.webp?itok=BJ-4muzp)
This output has been shortened as it is very verbose. However, you receive a large amount of information with this command. From left to right, we have the PID, USER, CGROUP, and COMMAND.
I find that this output is a great way of seeing exactly which process belongs to which parent job. It's also in a fairly user-friendly format. The command itself can be a lot to type out on a regular basis, so I recommend setting up a shell alias. For more information on how to create an alias, see my article on the subject here. For now, something like this would be appropriate:
alias pscgroup='ps xawf -eo pid,user,cgroup,args'
Method two
The next option we will look at is a systemd
utility. This method is an even better way, in my humble opinion, to see which job belongs to which parent process or owner. When you type this:
[root@fed31 ~]# systemd-cgls
the result might look like this:
![systemd control groups example](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2019-12/Screen%20Shot%202019-12-05%20at%2012.04.12%20PM.png.webp?itok=hBiP73d3)
Again, the screenshot has been shortened due to the length of the output. In this version, you can more easily see which process belongs to which user, plus each process shows its child processes as subsets of information. This method is a super simple way to see the organization of processes and find ownership quickly.
These two methods of viewing processes helped me to get a grasp of what owns what. Hopefully, you will find these helpful as well!
[Want to try out Red Hat Enterprise Linux? Download it now for free.]
저자 소개
Tyler is the Sr. Community Manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! He was first introduced to Red Hat in 2012 by way of a Red Hat Enterprise Linux-based combat system inside the USS Georgia Missile Control Center. Now that he has surfaced, he lives with his wife and son near Raleigh, where he worked as a data storage engineer before finding his way to the Red Hat team. He has written numerous technical documents, from military procedures to knowledgebase articles and even some training curricula. In his free time, he blends a passion for hiking, climbing, and bushcraft with video games and computer building. He is loves to read and enjoy a scotch or bourbon. Find him on Twitter or on LinkedIn.
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
오리지널 쇼
엔터프라이즈 기술 분야의 제작자와 리더가 전하는 흥미로운 스토리
제품
- Red Hat Enterprise Linux
- Red Hat OpenShift Enterprise
- Red Hat Ansible Automation Platform
- 클라우드 서비스
- 모든 제품 보기
툴
체험, 구매 & 영업
커뮤니케이션
Red Hat 소개
Red Hat은 Linux, 클라우드, 컨테이너, 쿠버네티스 등을 포함한 글로벌 엔터프라이즈 오픈소스 솔루션 공급업체입니다. Red Hat은 코어 데이터센터에서 네트워크 엣지에 이르기까지 다양한 플랫폼과 환경에서 기업의 업무 편의성을 높여 주는 강화된 기능의 솔루션을 제공합니다.