Processes Lab


 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Processes Lab
# 1  
Old 03-09-2013
Processes Lab

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

Here are my directions. I am pretty sure I am doing this right, but I just want someone more experienced to look over my work. Thank you.

There are two parts. It seems long but it's not. For both I need to record my inputs into a script file :

Part 1:

1) Start the command "sleep 6000" in the background
2) Use ps to determine its status
3) Redirect the ps command to a file
4) Kill the sleep process
5) Run ps to verify the process is dead.

Part 2: (Working with multiple processes)

1) Start up "sleep 6000" in the background
2) Start up "sleep 3000" with nohup in the background
3) Bring "sleep 6000" to the foreground
4) Suspend "sleep 6000"
5) Use ps or jobs to verify the state of all processes
6) Send a copy of ps to a file and print it
7) Kill both processes

2. Relevant commands, code, scripts, algorithms:

The relevant commands would be those located under processes, since that is the section we are working on now.


3. The attempts at a solution (include all code and scripts):

First I do "touch lab5file" to create a file, then I do "script lab5" to record my inputs (My teacher wants one script file for both parts - he does not want the output, just commands)

Part 1:

1. sleep 6000 &
2 + 3. ps > /var/home/stud3/jgeiger/lab5file
4. kill -9 <PID number here>
5. ps

Part 2:

1. sleep 6000 &
2. nohup sleep 3000 &
3. fg %<job number for sleep 6000 here>
4. ctrl + z
5 + 6. ps > /var/home/stud3/jgeiger/lab5file
7. kill -9 <PID number for sleep 6000>
8. kill -9 <PID number for sleep 3000>

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Brookdale Community College - Lincroft, New Jersey - United States - Dr. Rick Bournique- COMP 145

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by Jagst3r21; 03-09-2013 at 11:26 PM.. Reason: course link
# 2  
Old 03-10-2013
Both your solutions will do the job. You didn't print as requested in 2.6, and you didn't mention the jobs' statuses. What status would you expect them in?
Use kill -9 only as a last resort for otherwise unaccessible processes. Usually, the default 15 (TERM) is sufficient. And, you can list several processs to kill in one command.
# 3  
Old 03-10-2013
Your solutions are correct to the point that they are working. The following is just a bit of additional information you might find useful. I noticed, that you have no solution for question 2.7, probably an oversight?

RudiC is correct: "kill -9" means the OS actively terminates the process. "kill -15" on the other hand tells the process to shut down immediately. In your case this will not make that much difference, but if a process has open temporary files or logs to be written, or any other allocated resources, "kill -15" will allow it to neatly close all these before exiting while "kill -9" will leave all these open and hanging in limbo.

I don't know which shell you use, but most probably it is either bash or ksh. In both cases you can make use of the job control of this shell: issue "jobs" to see a list of jobs in the background and use "kill %<number>" instead of "kill <PID>" to address the process.

The "kill" command can take a list of PIDs to process. Instead of

Code:
kill -9 <PID1>
kill -9 <PID2>
kill -9 <PID3>
...

it is posssible to write

Code:
kill -9 <PID1> <PID2> <PID3> ...

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 4  
Old 03-10-2013
Thanks for the responses and tips. How come for 2.3 I cannot enter another command? After I do
Code:
fg %<job number for sleep 6000 here>

I do not get the dollar sign back to proceed and do
Code:
ctrl + z

for
Code:
nohup sleep 3000 &

. I realize now that I am not sure how to make the ctrl + z targets the nohup sleep 3000 & command either.

Thanks again in advance,

James
# 5  
Old 03-10-2013
Quote:
Originally Posted by Jagst3r21
How come for 2.3 I cannot enter another command? After I do
Code:
fg %<job number for sleep 6000 here>

I do not get the dollar sign back to proceed and do
Code:
ctrl + z

for
Code:
nohup sleep 3000 &

.
I'd say works as designed. ;-)) "fg" is the command to get to the FOREGROUND a process which was previously put into the BACKGROUND (or has been suspended). As long as a process is running in the foreground you get no prompt (it is often a dollar sign, but it doesn't have to), because the prompt display is the shells way of saying "there is no process in foreground so i am ready for input".

Quote:
Originally Posted by Jagst3r21
I realize now that I am not sure how to make the ctrl + z targets the nohup sleep 3000 & command either.
Of all the processes running from your shell there can be none, one or several in the background and none or one (not several!) in the foreground. This answers the question: "CTRL-Z" or other job-control key sequences ("CTRL-C", for instance) only affect the process running in the foreground.

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Hardware

Lab server organized software

Hello, Do you have any suggestion of any tool (web based preferably) about how to organize a lab environment? Now i save some info in excel sheet (one rack per column) , but i was thinking if any software exists. Thanks in advance! (2 Replies)
Discussion started by: @dagio
2 Replies

2. Homework & Coursework Questions

System Admin. Lab

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Create a group id with your last name. Create 2 user IDs using your last name and the numbers 1 and 2. For each... (3 Replies)
Discussion started by: Jagst3r21
3 Replies

3. Homework & Coursework Questions

Lab ^

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Filter a file for lines that have exactly 5 numbers in a row. 2. Relevant commands, code, scripts,... (13 Replies)
Discussion started by: herb bertz
13 Replies

4. Hardware

Electricity Savings for home lab

So, I have a kindof off the wall question. I've got 10 computers which I inherited from a charter school that closed that I did their admin work for. They're not servers, just workstations with ubuntu server running on them. I had them all up and running at one point... but crimineys the load on my... (8 Replies)
Discussion started by: jtollefson
8 Replies

5. Shell Programming and Scripting

help me with lab im new to bash....

Write a script that copies the file tree (including subdirectories) in your home directory. As the initial directory to take the directory / usr / share / doc, as the destination directory using the directory $ {HOME} / doc. Write a script corresponding to paragraph 1. Additional conditions: a)... (1 Reply)
Discussion started by: elginmulizwa
1 Replies

6. Homework & Coursework Questions

shell scripting while loop lab 15 help

hi.. this is shell scripting lab15.sh i dont understand this lab i am at the screen shot part. i was wondering if someone can take a quick look at this lab i have linked the doc below. i dont know where to start i have did the Required Errorlevels Errorlevel # but dont... (1 Reply)
Discussion started by: beerpong1
1 Replies

7. Homework & Coursework Questions

Help completing lab.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: ''you are missing the /home/smichaels/Labs/lab2b/group file, please create it as per step 12 of the lab. once... (4 Replies)
Discussion started by: ink
4 Replies

8. Shell Programming and Scripting

cant complete lab ???

heres the lab i did everything but when i issue the automated lab check. but it gives me this everytime ''you are missing the /home/smichaels/Labs/lab2b/group file, please create it as per step 12 of the lab. once you have corrected this problem, re-run the uli101.023 program'' im... (1 Reply)
Discussion started by: ink
1 Replies

9. Programming

Shell Script Lab

In the following Shell Script can anyone help me? What are the total scripts? What are the total binaries? What are the total files? #!/bin/sh GREP="/bin/grep -q" if ; then if ; then for | in ${I}/* ;do file ${I} | ${GREP} "executable" && echo "${I} is a binary" file ${I} |... (1 Reply)
Discussion started by: rktompsett
1 Replies

10. UNIX for Dummies Questions & Answers

VMWare Workstation for home lab

I was wondering if anyone has used VMWare Workstation? I wanted to practice and learn Unix in a networking environment and have my own home lab. However room and money prevent me from buying several computers to do so. Any input would help thank you. (0 Replies)
Discussion started by: vedder191
0 Replies
Login or Register to Ask a Question