20220324 152400
Job Control

process management

ps -e
ps -ef
ps -aux

ps -eo user,pid,ni,cmd

kill pid or kill -15 pid –terminate process

kill -9 pid –kill process
——————————–
foreground process:
-process runs on terminal
-once process is done , it exits
-terminal will back- we can do cmds

-running process show on screen

backgroup process:

-process runs on backgroup
-does not shows on screen
-it exits once process is done in background

-running process not show on screen

————————————–
to start and run any process in background

cmd &

sleep 100 &
——————-
sleep 1000 &
[1] 8549
sleep 2000 &
[2] 8553
sleep 3000 &
[3] 8558
ps -j
PID PGID SID TTY TIME CMD
5672 5672 5672 pts/1 00:00:01 bash
8549 8549 5672 pts/1 00:00:00 sleep
8553 8553 5672 pts/1 00:00:00 sleep
8558 8558 5672 pts/1 00:00:00 sleep
8571 8571 5672 pts/1 00:00:00 ps

jobs
[1] Running sleep 1000 &
[2]- Running sleep 2000 &
[3]+ Running sleep 3000 &

fg %2
sleep 2000
^Z
[2]+ Stopped sleep 2000

jobs
[1] Running sleep 1000 &
[2]+ Stopped sleep 2000
[3]- Running sleep 3000 &

bg %2
[2]+ sleep 2000 &

jobs
[1] Running sleep 1000 &
[2]- Running sleep 2000 &
[3]+ Running sleep 3000 &
——————————————-
gedit &
[1] 8893

jobs
[1]+ Running gedit &

fg %1
gedit
^Z
[1]+ Stopped gedit

jobs
[1]+ Stopped gedit

bg %1
[1]+ gedit &

jobs
[1]+ Running gedit &
——————————————–

nice – run a program with modified scheduling priority

Niceness values range from -20 (most favorable to the process)
to 19 (least favorable to the process)

-20 -very high
-10 -high
0 -normal
10 -low
19 -very low
——————————————–
nice -n -10 sleep 1500 & — run sleep 1500 process with nice -10

nice -n 10 sleep 1300 & — run sleep 1300 process wiht nice 10

ps -eo user,pid,ni,cmd | grep sleep
student+ 8549 0 sleep 1000
student+ 8553 0 sleep 2000
student+ 8558 0 sleep 3000
student+ 9186 10 sleep 1300
root 9287 0 sleep 60
root 9304 -10 sleep 1500
————————————-

renice — to change nice value of a process– change priority

renice -n -15 8549
8549 (process ID) old priority 0, new priority -15
ps -eo user,pid,ni,cmd | grep sleep
student+ 8549 -15 sleep 1000
student+ 8553 0 sleep 2000
student+ 8558 0 sleep 3000
student+ 9186 10 sleep 1300
root 9304 -10 sleep 1500
root 9405 0 sleep 60

renice -n 5 8553
8553 (process ID) old priority 0, new priority 5

ps -eo user,pid,ni,cmd | grep sleep
student+ 8549 -15 sleep 1000
student+ 8553 5 sleep 2000
student+ 8558 0 sleep 3000
student+ 9186 10 sleep 1300
root 9304 -10 sleep 1500
root 9464 0 sleep 60
———————————————-
top – display Linux processes

top

k

pid

9 or 15

———————————————-

source

LEAVE A REPLY

Please enter your comment!
Please enter your name here