linux 进程 输出重定向 屏幕,请教一个linux进程输出重定向问题?

目前在bash终端依次执行如下三条命令:

1:

php test.php >> test.log

2:

python test.py >> test.log

3:

sh test.sh >> test.log

并且在另一个窗口执行:

tail -f test.log

其中1 php和3 bash可以实时在test.log中写入,

但是为什么python只会在python程序结束之后才会在test.log中写入?

并且像这样:

echo "cd $test_dir && /usr/bin/python test.py &" >> test_py.sh && sh test_py.sh

将python放入sh脚本中执行也不行

附:

1 test.php

$i = 1;

while (True) {

sleep(1);

print $i++ . "\r\n";

if ($i > 10) {

break;

}

}

?>

2 test.py

#!/usr/bin/python

# coding=utf-8

import time

i = 1

while True:

i += 1

print i

time.sleep(1)

if i > 10:

break

print "----------end-----------"

3 test.sh

#!/usr/bin/env bash

# cd /Users/cg/MyFiles/test && /usr/bin/python cgcg.py &

i=1

while [[ 1 ]]; do

sleep 1

i=`expr $i + 1`

echo $i

done

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值