Exercise: Processes review
Run a small batch of work as a service user on servera: one process that survives a hangup, one that you reprioritise and pause, one that you end cleanly, and a tuned profile for the server.
Processes review
- Start protected, reprioritised and paused processes as another user.
- End a process with the right signal.
- Install tuned and select a profile.
Before you start: reset the servers and complete this chapter's lessons. You work on servera as root (sudo -i); lab start and lab grade run on workstation. The grader looks at what is running at that moment, so leave the processes in place until you have graded.
- Create the user
worker. Asworker, startsleep 7000in the background so that it survives a closed terminal, with niceness 5. - As
worker, startsleep 7001in the background, change its niceness to 12 and pause it with a signal (it must be stopped, not ended). - As
worker, startsleep 7002, then end it with the default signal. - Install
tuned, enable and start it, and select the profilethroughput-performance. - On workstation, fill in the signal numbers in
answers.txt.
Start the exercise
[student@workstation ~]$ lab start sa-proc-review
[student@workstation ~]$ cd ~/sa-proc-review
[student@workstation sa-proc-review]$ ssh student@servera
[student@servera ~]$ sudo -i
[root@servera ~]#Create worker and start the three processes
[root@servera ~]# useradd -m worker
[root@servera ~]# su - worker -c 'nohup nice -n 5 sleep 7000 >/dev/null 2>&1 &'
[root@servera ~]# su - worker -c 'nohup sleep 7001 >/dev/null 2>&1 &'
[root@servera ~]# su - worker -c 'nohup sleep 7002 >/dev/null 2>&1 &'
[root@servera ~]# pgrep -u worker -a sleep
5101 sleep 7000
5102 sleep 7001
5103 sleep 7002The nohup and & keep each process alive after su returns.
Reprioritise, pause and end
[root@servera ~]# renice -n 12 -p $(pgrep -f '^sleep 7001Loading…
#39;)
5102 (process ID) old priority 0, new priority 12
[root@servera ~]# kill -STOP $(pgrep -f '^sleep 7001Loading…
#39;)
[root@servera ~]# kill $(pgrep -f '^sleep 7002Loading…
#39;)
[root@servera ~]# ps -o pid,user,ni,stat,cmd -C sleep
PID USER NI STAT CMD
5101 worker 5 SN sleep 7000
5102 worker 12 TN sleep 7001Loading…STAT T shows the paused process; 7002 is gone. Using pgrep -f '^sleep 7001 matches the whole command line exactly, so it cannot hit a different sleep.
Install tuned and choose the profile
[root@servera ~]# dnf install -y tuned
...output omitted...
[root@servera ~]# systemctl enable --now tuned
[root@servera ~]# tuned-adm profile throughput-performance
[root@servera ~]# tuned-adm active
Current active profile: throughput-performanceRecord the signal numbers and grade
Leave servera, then on workstation edit answers.txt (use kill -l to look the numbers up) and grade:
Check your work with lab grade sa-proc-review, then put the exercise away with lab finish sa-proc-review.