Sleep until a specific time/date

前端 未结 18 2144
栀梦
栀梦 2020-11-28 21:13

I want my bash script to sleep until a specific time. So, I want a command like \"sleep\" which takes no interval but an end time and sleeps until then.

The \"at\"-d

18条回答
  •  忘掉有多难
    2020-11-28 21:30

    Use tarry. It's a tool I wrote to specifically do this.

    https://github.com/metaphyze/tarry/

    This is a simple command line tool for waiting until a specific time. This is not the same as "sleep" which will wait for a duration of time. This is useful if you want to execute something at a specific time or more likely execute several things at exactly the same time such as testing if a server can handle multiple very simultaneous requests. You could use it like this with "&&" on Linux, Mac, or Windows:

       tarry -until=16:03:04 && someOtherCommand
    

    This would wait until 4:03:04 PM and then execute someOtherCommand. Here's a Linux/Mac example of how to run multiple requests all scheduled to start at the same time:

       for request in 1 2 3 4 5 6 7 8 9 10
       do
           tarry -until=16:03:04 && date > results.$request &
       done
    

    Ubuntu, Linux, and Windows binaries are available through links on the page.

提交回复
热议问题