Reputation: 514
I have a bash
script.I want to kill command in less then one second time.
#!/bin/sh
for ((i=0; i<=$1; i++)); do ssh "$2$i" 'uptime;free -m;mpstat;cat /tmp/db2.info'; done &
pid=$!
sleep 2
kill -9 $pid
Upvotes: 1
Views: 4254
Reputation: 158130
If you are using sleep
from GNU coreutils, you can pass decimals as argument. Like this:
sleep 0.1
All Linux systems should have this version of sleep. If your code needs to run on BSD and other *NIXes too I would encourage you to write the script in a language like perl, python or ruby which has something like usleep()
.
Upvotes: 7