Shell script spawning a process after a delay

Can't try it right now but

(sleep 60 && echo "A")&

should do the job


& starts a background job, so

sleep 60 && echo "A" &

A slight expansion on the other answers is to wait for the backgrounded commands at the end of the script.

#!/bin/sh
# Echo A 60 seconds later, but without blocking the rest of the script

set -e

sleep 60 && echo "A" &
pid=$!

echo "B"
echo "C"

wait $pid

Alternative:

echo 'echo "A"' | at now + 1 min

If somehow the OS is not running at the specified time, the command will be executed as soon as it is available.

Tags:

Shell

Bash