Fedora help

cyclones

In Runtime
Messages
483
Location
USA
Hello. I am trying to work on some school work, but seem a little stumped here. We are asked to run a script through terminal that pretty much just keeps repeating and repeating itself. Here is the code:
#!/bin/bash

let i=0

while true
do
echo $i
if [ $i -gt 100 ]
then
let i=0
fi
let i=i+1
done

--
When I ran that command in one terminal window, and then I open up another command window and do the ps command which shows me what processes are running, but it doesn't list it as a process running. Why? How come it doesn't display it?

Thanks
 
My guess is since it's bash (a command interpreter) it's keeping it inside that terminal process, not creating a new process. If you were to make a C/C++ program and run it from terminal, it would launch a new process, which would show up under the ps command from a new window (because new memory space was allocated for the separate program and ran). But, like I said, since you're running a bash command, it's keeping it in the existing terminal process (similar to how Command Prompt works in Windows if you run a batch file).
 
do
Code:
ps a | grep scriptname
or just "ps a"
It shows up with that

EDIT: Or plain ol' "top" or "htop" will show them as well
 
Back
Top Bottom