I'm working on a linux server which is sometimes very slow. So when i add some jobs to run for me i have to wait for a few hours just to run a simple calculation.
I was wondering if i am able to start the next analysis but let it wait until the output of the previous analysis is there. (the second analysis needs the first analysis output)
I tried to make except and other options working but still no success (found except and other options in previous question on stackoverflow):
Any ideas/hints are appreciated and will help me allot.
The only thing i want is to let the second scrip wait till the text file of the first script is given.
The 4 scripts:1.
. ./script2.sh $repla
. ./script3.sh $replac
for i in 'abcdefghijklmnopqrst'
repla=`echo $i | sed 's/'abc'/'xyz'/g'`
for j in $1
replac=`echo $j | sed 's/'xyz'/'san'/g'`
for h in $1
replace=`echo $h | sed 's/'san'/'sander'/g'`
You can use
wait if you know the pid of the process running in background. Wait will also return the same exit code of the process it is waiting to stop.
firstProcess & # Running in background firstPid=$! otherProcess # Concurrent with firstProcess wait $firstPid # Wait firstProcess finish anotherProcess
you can use below core with some modifications
#!/bin/bash while [ ! -f FILE_NAME ] do sleep SOME_SECONDS done echo "file found"
Instead of executing multiple scripts independently you should create a
master script runner like this:
#!/bin/bash # sanity checks & parse arguments ./script1 ret=$? # check for return value of script1 using $ret variable ./script2 ret=$? # check for return value of script2 using $ret variable ./script3 ret=$? # check for return value of script3 using $ret variable ... # do cleanup and reporting