bash脚本中的输出重定向不起作用

时间:2012-10-08 23:46:38

标签: bash outputstream fileoutputstream

我有一个脚本,可以确保进程继续运行,并将进程的输出重定向到相应的process_name.out文件。

神秘地(对于我至少),输出不会被重定向到文件,除非我在错误的情况下关闭脚本。

这方面的任何线索都会非常有用。

#!/bin/bash

until $1 >> "/root/$1.out" 2>>"/root/$1.log" ; do
    echo "Server $1 crashed with exit code $?.  Respawning.." >> "/root/procees.log"
    sleep 1
done

1 个答案:

答案 0 :(得分:1)

其中一条评论中提到的@shelter解决方案是使用

until unbuffer $1

代替

相关问题