Run shell scripts in order

0 votes
asked Dec 29, 2013 by midimo

I have 3 commands that I am trying to run when the system start as a cronjob.

# Sleep at startup
sleep 2m
#command num 1:
./trace.out
sleep 5
#Command num 2:
java -jar file.jar
sleep 5
#Command num 3:
sh ./script.sh

is there any way to make this script more efficient using a loop, some way to make sure every script is running before executing the next one.

1 Answer

+1 vote
answered Nov 29, 2018 by hmm

I would use && between each command as it executes each command, only if the previous one succeeded! For example:

# Sleep at startup
sleep 2m
./trace.out && java -jar file.jar && sh ./script.sh
Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...