Is there a timer command in the terminal? [duplicate]
Sophia Terry
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 +60But say I want to do as described above:
command X -time 60 ls -aIs there something like this and if not could I add it myself?
01 Answer
You could run it like this:
sleep 60 && ls -aBut 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.
1