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

前端 未结 8 1167
隐瞒了意图╮
隐瞒了意图╮ 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:46

    If they are in the same directory as your script that contains:

    ./a.sh > /dev/null 2>&1 &
    ./b.sh > /dev/null 2>&1 &
    

    The & at the end is what makes your script run in the background.

    The > /dev/null 2>&1 part is not necessary - it redirects the stdout and stderr streams so you don't have to see them on the terminal, which you may want to do for noisy scripts with lots of output.

提交回复
热议问题