0

I have a bash script with the following command

command1 < input.txt > output.txt

When I run it, the output.txt file is created and filled with almost 5mb of data. The problem is that when its it's run by cron it doesn't work. It creates the file output.txt but it's empty. I believe that what's happening is that it's not reading the input from input.txt so command1 exits right away, creating the output file but don't printing anything.

Anyone knows what is happening and how can it be fixed?

EDIT: After trying a lot of options it appears that the problem is that the cron is configured to redirect stdin, so no matter if I redirect stdin or if I pipe processes, nothing is able to read anything from stdin. ¿Any solution?

4

1 回答 1

0

以超级用户身份登录并使用“env”调用您的命令。

env -i  command1 < input.txt > output.txt

有了这个,您可以(几乎)在 cron 具有的条件下运行命令。然后,您将收到描述您的问题的错误消息。

于 2013-07-26T12:27:08.447 回答