Bash sleep in milliseconds

后端 未结 3 1606
别那么骄傲
别那么骄傲 2020-12-15 03:07

I need a timer which will work with milliseconds. I tried to use sleep 0.1 command in a script, but I see this error message:

syntax error: invali

3条回答
  •  独厮守ぢ
    2020-12-15 03:58

    Bash was complaining about decimal values,

    read: 0.5: invalid timeout specification

    I came around with this solution which works great.

    sleep_fraction() {
      /usr/bin/perl -e "select(undef, undef, undef, $1)"
    }
    
    sleep_fraction 0.01428
    

提交回复
热议问题