Page 1 of 1
*nix - useing the DO statement
Posted: Thu Aug 21, 2008 7:17 pm
by Cuda68
I am trying to monitor a process on a PID or process, lets say mozilla-firefox, whatever. I would like to execute this at the command line where it would run every 15 minutes or so to give me an update on its progress. I have gotten this far but I am stuck with it not working.
[cuda@localhost ~]$ while loop
> do
> ps -ew | grep mozilla-firefox
>
>
> done
bash: loop: command not found
[cuda@localhost ~]$
Any ideas on how to make this work, I know it missing the time to repeat because I don't know what it is.
Posted: Thu Aug 21, 2008 7:24 pm
by heftig
If the script is doing something completely automated and you don't need to watch it i'd recommend using the chronograph service (cron). Fully automatic execution at specified times or intervals without user intervention.
If you need to watch the script's output, use the \"watch\" program.
Code: Select all
watch -n 1 \"ps -ew | grep apache2\"
Posted: Thu Aug 21, 2008 8:11 pm
by Cuda68
yea, but it controls the session. I only have n amount of sessions and was looking to set it in the back round. It will do the job though if I cant get the statement right.
Posted: Thu Aug 21, 2008 8:24 pm
by Jeff250
Are you trying to do an infinite loop? Try:
Re:
Posted: Thu Aug 21, 2008 8:27 pm
by Cuda68
Jeff250 wrote:Are you trying to do an infinite loop? Try:
Yes that's it woohoo, now I need to put a timer control on it. like making it run once or twice every 15 minutes to give me an update until the process quits.
Posted: Thu Aug 21, 2008 8:48 pm
by Jeff250
You can put a delay in the loop with:
or something analogous. Look in sleep's man pages for usage.
Posted: Thu Aug 21, 2008 8:55 pm
by Cuda68
yipper that's it, I just found it myself finally on Google.
Thanks alot for the assist, I am learning Perl scripts at work by being thrown into the fire. I did buy some books by Oreilly to help myself along but I am in the very beginning of learning. In a way this is so very cool and at the same time sucks.