Monday, January 20, 2014

Unix and Shell Programming - Background Process Manipulation

with 0 Comment
while true
do
echo "Background Process Manipulation"
echo "----------------------------------"
echo "Menu"
echo "------"
echo "1.Create a Background Process"
echo "2.List the Background Process"
echo "3.Kil a Process"
echo "4.Exit"
echo "Enter your choice"
read ch
case $ch in

1)
echo "Create a Background Process"
echo "------------------------------"
echo "Enter the Command to be Execute as Background"
read cmd
$cmd &
echo "$cmd Is Executed as a Background Process"
echo ""
;;

2)
echo "List the Current Process"
echo "-------------------------"
echo
ps
;;

3)
echo "Kill the Process"
echo "----------------"
echo
echo "Enter the Process id:"
read id
kill $id
echo $id "is Terminated"

4)
Exit
;;
esac
done

-----------
OUTPUT:
-----------
Background Process Manipulation
-----------------------------------
Menu
------
1.Create a Background Process
2.List the Background Process
3.Kil a Process
4.Exit

Enter your choice
1

Create a Background Process
-------------------------------
Enter the command to be Executed as Background
sleep300

sleep300 Is Executed as a Background Process

Enter your choice
2

List the Current Process
-------------------------
PID         TTY           TIME        CMD
4688   pts/15           00:00:00       bash
19739 pts/15           00:00:00        sh
19778 pts/15          00:00:00       sleep
19779 pts/15          00:00:00         ps

Enter your choice
3

Kill the Process
----------------
Ener the Process id:
19739

Terminated

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive