This is what my code looks like
master_script.sh
#!/bin/bash
chmod +x *
declare -A test=(
["echo1"]="sh `pwd`/echo1.sh"
["echo2"]="sh `pwd`/echo2.sh"
["echo3"]="sh `pwd`/echo3.sh")
log="$base_path"
for var in ${!test[@]}
do
`${test[$var]} >> $var.log`
echo "$var Started! :-)"
done
echoX.sh
scripts looks like this
#!/bin/bash
while true;do
echo "This is from Test1"
#some Code
echo "Eching the Output"
#some other code!
sleep 60
done
The idea is ok, but as you know, the control is waiting at ${test[$var]} >> $var.log
. Each echoX.sh
is while
loop, So the control is waiting to complete!. I want to start ALL scripts
How can I resolve this issue?. NOTE: There are future planings implement features like, staring single script like
./master_script.sh start echo1
, --> Will start only echo1
./master_script.sh stop echo1
---> Will stop only echo1
./master_script.sh start all
--> will starts all scripts
So, thats why I followed above procedure.
There are some other thoughts like.(Which don't want to do!)
echox.sh
#!/bin/bash
echo "This is from Test1"
#some Code
echo "Eching the Output"
#some other code!
nohup_echoX.sh
#!bin/bash
while true;do
./echoX.sh >> test.log 2>&1 &
done
Then in the mater_script.sh
, ill add the ./nohup_echoX.sh
in for
loop.
So, is there any way to implement this. And more thing, I saw(ps aux | grep <NAME>
), there are multiple instances of same process are running. So, how can I control this?