Run command after 1 hour in Linux

£可爱£侵袭症+ 提交于 2019-12-01 15:12:50

问题


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 command to run after 1 hour whatever the time it is.


回答1:


It is sleep 60m && ls




回答2:


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.



来源:https://stackoverflow.com/questions/33901726/run-command-after-1-hour-in-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!