Re: parallel bash scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/27/2012 05:25 PM, bruce wrote:
hi.

got a couple of test bash scripts.

dog.sh, cat.sh
each script runs the underlying php in an endless loop.

I'm trying to figure out how to run the scripts in parallel, from the
same parent shell script. something like:

test.sh


where dog.sh would be :
--------------------------------
while true
do
   pgrep dog
   if [ $? -ne 0 ]
   then
     /dog.php
   fi
sleep 5
done

my current tests, run dog.sh, which runs the dog.php ... but the test
never gets to run cat.sh

thoughts/comments...

thanks
Hey Bruce,

Do you mean to run these subprograms in parallel or in series?

cat.sh
#! /bin/bash

CAT=0
until [ $CAT -eq 10 ]
do
echo "Inside a dog it's too dark to read. $CAT"
CAT=$[$CAT + 1]
sleep 2
done


dog.sh
#! /bin/bash

DOG=0
until [ $DOG -eq 10 ]
do
echo "Next to a dog a book is man's best friend. $DOG"
DOG=$[$DOG + 1]
sleep 2
done


test.sh
#! /bin/sh

/home/mlapier/test/dog.sh 1>&2 &
/home/mlapier/test/cat.sh 1>&2 &


[mlapier@mushroom test]$ ./test.sh
[mlapier@mushroom test]$ Next to a dog a book is man's best friend. 0
Inside a dog it's too dark to read. 0
Next to a dog a book is man's best friend. 1
Inside a dog it's too dark to read. 1
Next to a dog a book is man's best friend. 2
Inside a dog it's too dark to read. 2
Next to a dog a book is man's best friend. 3
Inside a dog it's too dark to read. 3
Next to a dog a book is man's best friend. 4
Inside a dog it's too dark to read. 4
Next to a dog a book is man's best friend. 5
Inside a dog it's too dark to read. 5
Next to a dog a book is man's best friend. 6
Inside a dog it's too dark to read. 6
Next to a dog a book is man's best friend. 7
Inside a dog it's too dark to read. 7
Next to a dog a book is man's best friend. 8
Inside a dog it's too dark to read. 8
Next to a dog a book is man's best friend. 9
Inside a dog it's too dark to read. 9


--
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux