Linux - 在一段时间内重复执行命令

Sho*_*951 1 linux bash shell ubuntu centos

我知道命令监视-n的作用.我想做类似以下的事情:

watch -n 5 "ls" //Do this for 30 minutes, then stop.
Run Code Online (Sandbox Code Playgroud)

基本上我想每5秒重复一次命令,然后在30分钟后停止.我错过了停留30分钟的部分.我应该使用什么命令来实现这一目标?

谢谢.

Ipo*_*cer 5

使用超时:

timeout 1800 watch -n 5 "ls" 
Run Code Online (Sandbox Code Playgroud)