How to start a shell script in one minute later?
Suppose there are two bash files a.sh and b.sh
I want to execute b.sh one minute(or several seconds) after a.sh executed.
what should I code in a.sh ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Simple. you want to use ‘at’ to schedule your job. and ‘date’ to calculate your moment in the future.
Example:
or:
-v+60Sadds 60 seconds to current time. You can control exactly how many seconds you want to add.But usually, when people wants one program to launch a minute after the other, they are not 100% sure it will not take more or less than a minute. that’s it.
b.shcould be launched beforea.shis finished. ora.shcould have finished 30 seconds earlier than “planned” and b.sh could have started faster.I would recommend a different model. Where
b.shis launched first.a.shcreates a temp file when it starts. execute is tasks and delete its temp file at the end.b.shwatch for the temp file to be created, then deleted. and start its tasks.