script with a sequence of nohups

Hi,

I have written this script below to run a mathematica notebook, and then I want to launch another one when the first one finishes doing what it must. The notebook includes a command which will exit the program math. If I do it like below the two math processes begin at the same time, and this is not what I need. Perhaps I need an intermidiate command to stop the nohup.

Can you help me? Thanks

 

#!/bin/bash
nohup math < chain1.m
nohup math < chain2.m

have a play with:

#  date; sleep 5 && date
Tue Aug  4 12:30:34 BST 2009
Tue Aug  4 12:30:39 BST 2009

or

#   nohup sleep 5 & date ; wait ; date
[1] 50117
Tue Aug  4 12:30:58 BST 2009
Sending output to nohup.out
[1]+  Done                    nohup sleep 5
Tue Aug  4 12:31:03 BST 2009

HTH

I tried

nohup math < chain1.m ; sleep 5 && nohup math < chain2.m &

and did not do what I wanted. The question is math < chain 1. m takes more than 5 secs. So I guess I would have to calculate how long it is going to take and use this value in sleep.

What I need is something that works even if the time it takes to finish the first process in not known.

Thanks

erm - the sleep was just for example...

you should be able to just do:

cmd1 && cmd2 etc

or use wait to wait on the process...