ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Commands are executed synchronously unless you tell them not to be.
e.g. If you had a script that said:
ls -l
df -h
cat /etc/fstab
It would not start the "df -h" until the "ls -l" had completed. It would not start the "cat /etc/fstab" until the "df -h" had completed.
You can make it asynchronous by putting ampserand (&) after the commands:
ls -l &
df -h &
cat /etc/fstab &
All 3 commands would start as soon as the prior one had started without waiting for a return status.
Some commands do background themselves. You could put in sleep statements to wait for them to complete:
ls -l
sleep 10
df -h
sleep 5
cat /etc/fstab
It would wait 10 seconds after ls -l to start the df -h. It would wait five seconds after the df -h to start the cat /etc/fstab.
Thanks for your reply.
I have a script file myscript.sh.
I can run it like myscript.sh & in the background.
I can run more than one instances of myscript.sh & in the background.
I want these instances be run in FIFO manner.
Instead of running them with the "&" run them without it. That way it won't run the second myscript.sh until the first one has completed. That is the say it is the "&" that is making them go at the same time. Taking it out will make them go one after the other.
You really don't want to run several copies of the same script at the same time anyway because it hammers your CPU due to contention for the same resources.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.