How to start a shell script in one minute later in linux?
bash
Solution
Simple. you want to use 'at' to schedule your job. and 'date' to calculate your moment in the future.
Example:
echo b.sh | at now + 1 minute
or:
echo b.sh | at -t `date -v+60S "+%Y%m%d%H%M%S"`
`-v+60S` adds 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.sh` could be launched before `a.sh` is finished. or `a.sh` could have finished 30 seconds earlier than "planned" and b.sh could have started faster.
I would recommend a different model. Where `b.sh` is launched first. `a.sh` creates a temp file when it starts. execute is tasks and delete its temp file at the end. `b.sh` watch for the temp file to be created, then deleted. and start its tasks.
Problem
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 ?