1

I want to know if there is a command X that allows me to execute another command Y after a certain time. I would specify the time in X. The idea comes from a sleep timer, where I found: Shutdown after a certain time

With:

sudo shutdown -P +60

But say I want to do as described above:

command X -time 60 ls -a

Is there something like this and if not could I add it myself?

1 Answers1

4

You could run it like this:

sleep 60 && ls -a

But that blocks your shell until the wait is over.

To avoid the blocked terminal, group the commands:

{sleep 60 && ls -a ; } &

Be aware that the commands in braces are then executed in a subshell, e.g. variables defined there will not be available in the main shell.