更新时间:2022-10-14 23:09:13
你的脚本的第一行:
/#!/斌/庆典
实际上应该是:
#!/斌/庆典
我假设发帖时你的问题(但你可能要检查出来,以防万一),这只是一个错字。现在,如果我用LS -LAS替换命令1,它为我工作:
#!/斌/庆典而[1];做
LS -LAS |切-f 3
睡眠5;
DONE
注意,我只用LS改变你的命令1。
那么什么是命令1到底是什么?如果说,命令1的需求标准输入的输入(只是案例之一),你的工作可能会停止
I have writen a simple bash program. I want to run it as a background process. But it'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)