Bash loops

From Tech-Wiki
Revision as of 20:25, 25 April 2017 by Fabricio.Lima (Talk | contribs)

Jump to: navigation, search


Executing a Do loop to repeat one command with different hosts

# for num in {1..5}; do ssh host-$num "shutdown"; done
# for host in `cat hosts.txt`; do ssh $host "shutdown"; done

Executing the same command forever

# while true; do date +%s; done