Using bash write seperate functions that return the Priority

Using bash, write seperate functions that return the Priority number, Niceness value, and state (Running, sleeping, Disk Sleeping, stopped, zombie, dead) of a process when given a user provided pid.

Solution

ps command returns all the details of a process and user details.

PS -o will sort and give the result ,

For more understanding enter ps -l on command terminal.this will return all the details in list format.

Please find below bash script

!/bin/bash
print_PriorityNum () {
echo PID $1
ps -o pid,pri -p $1
}
print_Niceness () {
echo PID $1
ps -o pid,nice -p $1
}
print_State () {
echo PID $1
ps -o pid,state -p $1
}
echo -e \"Hi, please enter the PID : \\c \"
read pidval
print_PriorityNum pidval
print_Niceness pidval
print_State pidval

Using bash, write seperate functions that return the Priority number, Niceness value, and state (Running, sleeping, Disk Sleeping, stopped, zombie, dead) of a p

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site