I just want to echo my string after 1 hour. I saw at
command but it can run script at specific time (HH:MM
). I want my echo<
It is sleep 60m && ls
You can also use at (at is very good at understanding times, see this page for a lot of good examples).
> at now + 1 hour
at> echo 'my string' > /dev/stdout
at> ^D
After you input the at time specification it will take you to the at prompt (your OS my or my not show the at> prompt, OSX doesn't for example). You then type whatever commands you want executed and press Control-D to exit the at prompt. One caveat: at will run your commands and mail you the result. So if you want your output to appear on your terminal, you should direct your output to the appropriate device: /dev/stdout and /dev/tty usually work.
According to the sleep
man page, sleep
will
Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days. Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point number. Given two or more arguments, pause for the amount of time specified by the sum of their values.
So you can either use sleep 1h
, sleep 60m
or sleep 3600s
or just sleep 3600
to sleep for 1 hour and then execute your command ls
after that. For example sleep 1h && echo "hello world"
.