So, I was wondering if there was a bash command that lets me fork a process which sleeps for several seconds, then executes a command.
Here’s an example:
sleep 30 'echo executing...' &
^This doesn’t actually work (because the sleep command only takes the time argument), but is there something that could do something like this? So, basically, a sleep command that takes a time argument and something to execute when the interval is completed? I want to be able to fork it into a different process then continue processing the shell script.
Also, I know I could write a simple script that does this, but due to some restraints to the situation (I’m actually passing this through a ssh call), I’d rather not do that.
You can invoke another shell in the background and make it do what you want:
The default interval for sleep is in seconds, so the above would sleep for 30 seconds. You can specify other intervals like:
30mfor 30 minutes, or1hfor 1 hour, or3dfor 3 days.