PDA

View Full Version : Continous repeat a command in CLI



phe
3rd April 2008, 08:09 PM
Hello,

Exist there a possibility to execute a command in a terminal window(. eg. /sbin/ifconfig eth0) every 5 seconds?

thanks,

sideways
3rd April 2008, 08:18 PM
There are a few ways to do this, one is


while true; do /sbin/ifconfig eth0; sleep 5; done

( ctrl-c to exit )

jtang613
3rd April 2008, 08:19 PM
for (( ; ; )) do /sbin/ifconfig eth0; sleep 5; done

phe
3rd April 2008, 08:25 PM
Thanks !

phe

mwhidby
3rd April 2008, 10:34 PM
The 'watch' command is very useful for this sort of thing:


watch -n 5 /sbin/ifconfig

See the man page for other options.