开发者

Background job getting stopped

I have writen a simple bash program. I want to run it as a background process. But i开发者_运维知识库t's getting stopped. I do not want that to happen. Kindly help

/#!/bin/bash  

while [ 1 ]; do  
command1 | cut -f 3  
sleep 5;  
done  

OUTPUT:  
Linux# /tmp/program &  
[19] 20162  
Linux# Line 1  
0  

[19]+ Stopped /tmp/command

Output explanation:

Line 1 and 0 are the output , and this output should be displayed every 5 secs which is what i want.

What happens: After displaying Line 1 and 0, control hangs, I press enter, I get the Stopped message. Kindly help me get rid of this.


the first line of your script:

/#!/bin/bash 

should actually be:

#!/bin/bash 

I assume this was just a typo when posting your question (but you might want to check that out, just in case). Now, if i replace "command1" with an ls -las, it works for me:

#!/bin/bash

while [ 1 ]; do
ls -las | cut -f 3
sleep 5;
done

notice that i've only changed your "command1" by an ls.

so what is "command1" exactly? your job may be stopped if that "command1" needs stdin input (just one of the cases)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜