SlackwareThis Forum is for the discussion of Slackware Linux.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I'm running a bunch of scripts that start realplayer with vsound and can only start after previous scripts have finished (I think only 1 instance of vsound can operate at time). How can I put script in a "que" so that they start up once the running scripts have stopped?
Just create a script that waits kicks off each of the scripts in turn:
Say you have scripts: script1.sh, script2.sh and script3.sh
Just create a new script called masterscript.sh that has:
So long as none of the scripts include a background (e.g. has an & at the end of the line or the utility itself automatically backgrounds) they'll run sequentially.
If something is being backgrounded you'll have to test for it:
while ps -ef |grep <script1.sh>
do sleep 60
while ps -ef |grep <script2.sh>
do sleep 60
The above starts script1.sh then checks every minute to see if it is still running. If not it will proceed on to script2.sh. It then checks every minute to see if script2.sh is done and will kick off script3.sh.
Note that you may not want to check for "script#.sh" but rather the command that it contains.
Also the sleep is important to keep the script from chewing up CPU. Without a sleep it would quickly peg your CPU. Even a sleep 1 would be better than no sleep but 60 seconds isn't excessive.
I am not backgrounding my scripts. I have script1.sh and script2.sh and run them this way:
These scripts take hours to run, so during that time I make script3.sh and script4.sh. How do I add script3.sh and script4.sh to my masterscript so that script3.sh starts when script2.sh ends? It sounds like I do this instead:
and then update the script list in masterscript.sh while it is executing-is that right?
Last edited by linuxhippy; 09-02-2006 at 10:06 AM.
If script1.sh and script2.sh are already running (from masterscript.sh) then you can't add to masterscript.sh. You would create a new one (masterscript2.sh) that would test for completion of script1.sh and script2.sh then run script3.sh:
while ps -ef |egrep "script1.sh|script2.sh" |grep -v egrep
do sleep 60
while ps -ef |grep script4.sh
do sleep 60
Note I'd left out the grep -v earlier but shouldn't have. You need this so it doesn't find your grep process as the only one running. This is necessary so it doesn't incorrectly show the script running when all it actually found was your grep command.
egrep allows for multiple patterns - the quotes are necessary around the patterns and the pipe sign (|) means "or" for egrep.
You would do the above if it is running script1 or script2 already. I'd suggest you make the masterscript with all 4 scripts in it before the next time you start script1.