How to run a command in the background and get no output?

前端 未结 8 978
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 05:28

I wrote two shell scripts a.sh and b.sh. In a.sh and b.sh I have a infinite for loop and they print some output to the te

8条回答
  •  有刺的猬
    2020-12-04 05:51

    Redirect the output to a file like this:

    ./a.sh > somefile 2>&1 &
    

    This will redirect both stdout and stderr to the same file. If you want to redirect stdout and stderr to two different files use this:

    ./a.sh > stdoutfile 2> stderrfile &
    

    You can use /dev/null as one or both of the files if you don't care about the stdout and/or stderr.

    See bash manpage for details about redirections.

提交回复
热议问题