Open main menu

CDOT Wiki β

Changes

Tutorial8: Links / Process Management

No change in size, 12:28, 5 February 2020
INVESTIGATION 2: MANAGING PROCESSES
# Make certain that you are logged into your Matrix account.<br><br>
# Issue the following Linux command to make a directory:<br><span style="color:blue;font-family:courier;font-weight:bold">mkdir ~/processes</span><br><br>
# Issue the following Linux command: <span style="color:blue;font-family:courier;font-weight:bold">sleep 200700</span><br><br>'''NOTE:''' The sleep command just waits for a specified number of seconds before completing<br>in order to return to the shell prompt. It is useful in order to force a pause in a sequence of commands.<br><br># Notice that this process will run for 200 700 seconds, and is forcing the user to wait until this process finishes.<br>A process that is running in the terminal is referred to as a '''foreground process'''.<br><br>The Unix/Linux system is designed to allow users to send preemptive signals to manage those processes.<br><br>
# Press the key combination: <span style="color:blue;font-family:courier;font-weight:bold">&lt;ctrl&gt;&lt;c&gt;</span><br><br>You should notice that the process that was running in the foreground has been interrupted (i.e. terminated).<br>'''NOTE:''' The '''ctrl-c''' key combination sends '''SIGINT''' ('''Signal Interrupt''') to terminate a process that is running.<br><br>
# Reissue the Linux command: <span style="color:blue;font-family:courier;font-weight:bold">sleep 200700</span><br><br>
# Press the key combination: <span style="color:blue;font-family:courier;font-weight:bold">&lt;ctrl&gt;&lt;z&gt;</span><br><br>
# You should now see output similar to what is displayed below:<br><span style="font-family:courier;font-weight:bold">[1]+ Stopped sleep 200700</span><br><br>'''NOTE:''' This indicates that this process has been placed into the background.<br>This is useful in order to "free-up" the terminal to run other commands.<br><br>
# Clear your bash shell terminal.<br><br>
# Issue the following Linux command: <span style="color:blue;font-family:courier;font-weight:bold">jobs</span><br><br>You should see the following output similar that was displayed above:<br><span style="font-family:courier;font-weight:bold">[1]+ Stopped sleep 200700</span><br><br>This display indicates that this process (that is now in the background) has stopped.<br>In other words, the sleep command is NOT counting-down to zero to terminate.<br><br>NOTE: You need to use the '''bg''' command to run that process that was sent into the background.<br><br>
# Issue the following Linux command: <span style="color:blue;font-family:courier;font-weight:bold">bg</span><br><br>'''NOTE:''' You can use the bg command WITHOUT arguments to specify the most recent process<br>that was placed into the background. From the '''jobs''' command, the process that has a plus sign "+"<br>indicates the most recent process placed into the background.<br><br>
# Issue the following Linux command: <span style="color:blue;font-family:courier;font-weight:bold">jobs</span><br><br>You should see the following output similar that was displayed above:<br><span style="font-family:courier;font-weight:bold">[1]+ sleep 200 700 &</span><br><br>This display indicates that this process in the background is running in the background<br>(denoted by the ampersand character "&"). Now the command is counting-down to zero.<br><br>
# Issue the following Linux command: <span style="color:blue;font-family:courier;font-weight:bold">fg</span><br><br>You should notice that the sleep command is now running in the foreground.<br><br>'''NOTE:''' You can use the fg command WITHOUT arguments to specify the most recent process<br>that was placed into the background. From the '''jobs''' command, the process that has a plus sign "+"<br>indicates the most recent process placed into the background.<br><br>
13,420
edits