When you start a process (run a command), there are two ways you can run it: Foreground Processes Background Processes Foreground Processes: By default, every process that you start runs in the foreground. It gets its input from the keyboard and sends its output to the screen. Background Processes: A background process runs without being connected to your keyboard. If the background process requires any keyboard input, it waits. The advantage of running a process in the background is that you can run other commands; you do not have to wait until it completes to start another! The simplest way to start a background process is to add an ampersand ( &) at the end of the command. Stopping Processes: If a process is running in background mode then first you would need to get its Job ID using ps command and after that you can use kill command to kill the process as follows: $ps -f UID PID PPID C STIME TTY TIME CMD amrood6738 3662 0 10:23:03 pts/6 0:00 first_one amrood6739 3662 0 10:22:54 pts/6 0:00 second_one amrood3662 3657 0 08:10:53 pts/6 0:00 -ksh amrood6892 3662 4 10:51:50 pts/6 0:00 ps -f $kill 6738 Terminated Here kill command would terminate first_one process. If a process ignores a regular kill command, you can use kill -9 followed by the process ID as follows: $kill -9 6738 Terminated Question Execute and document the commands to: Run a process in background Run a process in foreground Call the process from background to foreground
When you start a process (run a command), there are two ways you can run it:
-
Foreground Processes
-
Background Processes
Foreground Processes:
By default, every process that you start runs in the foreground. It gets its input from the keyboard and sends its output to the screen.
Background Processes:
A background process runs without being connected to your keyboard. If the background process requires any keyboard input, it waits.
The advantage of running a process in the background is that you can run other commands; you do not have to wait until it completes to start another!
The simplest way to start a background process is to add an ampersand ( &) at the end of the command.
Stopping Processes:
If a process is running in background mode then first you would need to get its Job ID using ps command and after that you can use kill command to kill the process as follows:
$ps -f
UID PID PPID C STIME TTY TIME CMD amrood
6738 3662 0 10:23:03 pts/6 0:00 first_one amrood
6739 3662 0 10:22:54 pts/6 0:00 second_one amrood
3662 3657 0 08:10:53 pts/6 0:00 -ksh amrood
6892 3662 4 10:51:50 pts/6 0:00 ps -f
$kill 6738
Terminated
Here kill command would terminate first_one process. If a process ignores a regular kill command, you can use kill -9 followed by the process ID as follows:
$kill -9 6738
Terminated
Question
Execute and document the commands to:
-
Run a process in background
-
Run a process in foreground
-
Call the process from background to foreground
Step by step
Solved in 2 steps with 10 images