133k views
2 votes
Unix. List the commands that will perform the following tasks.

2. (Terminate any jobs running in the background before beginning this task.)
a) Start a sleep 1000 command in the background
b) Start a sleep 2000 command in the background
c) Suspend the sleep 1000 without bringing it to the foreground
d) Show the runtime status of the command using a ps command
Explain how you know the job is suspended
(You can just use the echo command to display a one line explanation.)
e) Restart the sleep 1000 command without bringing it to the foreground
f) Verify that the job is running with an appropriate command.
g) Terminate the sleep 1000 job (kill it) without bringing it to the foreground
h) Terminate the sleep 2000 job (kill it) without bringing it to the foreground
i) Verify that neither job is running anymore

User Lorean
by
7.6k points

1 Answer

3 votes

Final answer:

To terminate the sleep 2000 job without bringing it to the foreground, use the 'kill' command followed by the PID. Verify that neither job is running using the 'ps' command.

Step-by-step explanation:

To terminate the sleep 2000 job without bringing it to the foreground, you can use the 'kill' command followed by the process ID (PID) of the job. The 'kill' command can send various signals to a process, and by default, it sends a TERM (termination) signal. To determine the PID of the sleep 2000 job, you can use the 'ps' command and filter the output using 'grep'. Here's an example:

$ ps -ef | grep sleep

USERNAME PID TTY TIME CMD
user 12345 pts/0 00:00:01 sleep 2000

$ kill 12345

To verify that neither job is running anymore, you can use the 'ps' command and check the process table. If the job is terminated successfully, it won't appear in the process table. Here's an example:

$ ps -ef | grep sleep

If the job is no longer running, the 'ps' command won't display any matching output. This indicates that both jobs have been terminated.

User Loshkin
by
8.2k points