Run command after 1 hour in Linux

前端 未结 3 566
没有蜡笔的小新
没有蜡笔的小新 2021-01-07 18:51

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<

3条回答
  •  青春惊慌失措
    2021-01-07 19:44

    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".

提交回复
热议问题