|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
[Solved] Script doesn't work..help?
hi, i am trying to run this script.the name of script is final.sh after i run it: Code:
#./final.sh & i grep the command Code:
# ps -a | grep bash and i see more then one processes runing 3!!
how can i solve this problem? my target script must always run in background and watch there are always 5 process that are runing and if there is less it should get them up untill 5. Code:
#! /bin/bash while true ; do proc_num=$(ps -a | grep bash | wc -l) while(( "$proc_num" < "5")) ; do bash #add a single process done sleep 10 done done #let something else use the box done Last edited by jim mcnamara; 01-09-2013 at 06:11 AM.. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
"bash" is a shell, not a script. If you search for "bash" in the process list you will find your scripts (because the use "bash" as their environment), but also interactive shells, login shells, other running scripts, etc.. Better use a more specific search term, which specifically finds your scripts instances and nothing else.
I hope this helps. bakunin |
| The Following User Says Thank You to bakunin For This Useful Post: | ||
zigizag (01-09-2013) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
instead of running bash let say it is another script..
the problem is the same...
|
|
#4
|
||||
|
||||
|
Im very busy at the moment so have not much time to go in details...
The output of your ps might have helped us you know... (the complete!) Look at the line 3 of your script... |
| The Following User Says Thank You to vbe For This Useful Post: | ||
zigizag (01-09-2013) | ||
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
instead of bash it is a script
the ps that i want to run is a script that runs application.
so instead of bash it is a script. 10x! |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
I just put your script in order ( for me to read...): Code:
#! /bin/bash
while true
do
proc_num=$(ps a | grep yourscript | wc -l)
echo "loop1: "proc_num=$proc_num
sleep 2
while (( $proc_num < 5 ))
do
echo "loop 2: "proc_num=$proc_num
sleep 2
yourscript & #add a single process
#sleep 1 # - this is for testing purpose... -#
#let proc_num=$proc_num+1
done
echo " out of loop 1 "
sleep 1
done
#let something else use the box doneComment: ps -a doesnt give the same as ps a you were missing a space after second while... My question is more on line launching yourscript: does it go in background like a daemon or not? if it doesnt I see your program being stuck at this point ( but I may be wrong since I dont know what program it is...) Last edited by vbe; 01-09-2013 at 11:27 AM.. |
| The Following User Says Thank You to vbe For This Useful Post: | ||
zigizag (01-10-2013) | ||
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
there is still a problem...
the .."$proc_num < 5 " doesnt work....it goes up and up and never stops of arising new scripts it runs more of my process.
alot of thanks!!! ---------- Post updated at 01:40 AM ---------- Previous update was at 01:39 AM ---------- there is still a problem... the .."$proc_num < 5 " doesnt work....it goes up and up and never stops of arising new scripts it runs more of my process. alot of thanks!!! ---------- Post updated at 01:45 AM ---------- Previous update was at 01:40 AM ---------- Hi, i tested on runing wireshark application and it arises more and more...never stops.. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| my script doesn't work :( | keiserx | Shell Programming and Scripting | 3 | 12-08-2010 02:00 AM |
| Script doesn't work in loop but does if not | bugeye | Shell Programming and Scripting | 6 | 08-03-2010 02:10 AM |
| Help with script.. it Just doesn't work | atmosroll | Shell Programming and Scripting | 1 | 02-23-2010 06:30 PM |
| gcd.sh script doesn't work... | kantze | Shell Programming and Scripting | 1 | 01-17-2008 08:46 PM |
| Script doesn't work, but commands inside work | cheongww | UNIX for Dummies Questions & Answers | 2 | 11-14-2006 09:52 PM |
|
|