简体   繁体   English

Bash Shell脚本循环未处理多个命令

[英]Bash Shell Script Loop not processing more than one command

Here's my loop: 这是我的循环:

#!/bin/bash
count=3

for i in $(seq $count)
do
   echo $i
   killall midori
   midori http://www.test.com/test.html?id=$i &
done

But it won't kill midori and launch another one in the background to continue the loop. 但是它不会杀死Midori并在后台启动另一个继续循环。 Any ideas? 有任何想法吗?

It most likely works exactly as you want it to, except you're killing midori within a millisecond of starting it, before it gets a chance to open a window or anything. 它最有可能按照您想要的方式工作,除了您在启动它的一毫秒内杀死Midori,然后才有机会打开窗口或任何东西。

Try adding a sleep to give it a chance to start up and do something before you kill it: 尝试增加sleep以使其有机会开始并在杀死它之前做一些事情:

#!/bin/bash
count=3

for i in $(seq $count)
do
   echo $i
   killall midori
   midori http://www.test.com/test.html?id=$i &
   sleep 10
done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM