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


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?


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.

  • This looks pretty good. I ll test it later. – Paul Erlenmeyer Nov 1 '19 at 9:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.