How to queue several jobs as consecutive and not simultaneous jobs?

Asked by cmaroun on 2012-02-09

Hello Ubuntu-ers,

I'm running Ubuntu 10.04 LTS on a 64-bit PC.

I have a series of jobs to run. The O/P of one is the I/P of the next one. How to queue these jobs so that I can send them all at the same time, but so that, for ex., job B awaits the end of job A before running? I couldn't find a way, even by changing NICE numbers .

Cheers,

CM

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu bash Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
2012-02-10
Last query:
2012-02-10
Last reply:
2012-02-09

Make a script, the next command will only run when the previous job finishes. A working example will clear this up (I assume you have gedit and firefox installed). Run:

gedit ~/wait1234; chmod +x ~/wait1234

in the file add these 3 lines:

#!/bin/bash
gedit
firefox

Save the file and close gedit. Now run:

./wait1234

gedit will open again, but not firefox. Close gedit and firefox will open. If you want commands to open in parallel you need to edit the script to look like this:

#!/bin/bash
gedit &
firefox

Not the ampersand on gedit. This means that it is backgrounded and the next command will run at the same time. You can see the new behaiour by rerunning:

./wait1234

HTH

cmaroun (rmaroun) said : #2

Thanks actionparsnip, that solved my question.