Repeat command automatically in Linux

前端 未结 13 1703
滥情空心
滥情空心 2020-12-04 04:54

Is it possible in Linux command line to have a command repeat every n seconds?

Say, I have an import running, and I am doing

ls -l
         


        
13条回答
  •  忘掉有多难
    2020-12-04 05:12

    To minimize drift more easily, use:

    while :; do sleep 1m & some-command; wait; done
    

    there will still be a tiny amount of drift due to bash's time to run the loop structure and the sleep command to actually execute.

    hint: ':' evals to 0 ie true.

提交回复
热议问题