开发者

bash script run forever in the background and stop messages

I have the following script

#!/bin/bash
php wes.php &
sleep 10
php wes1.php &
sleep 10
php wes2.php &
sleep 10
php wes3.php &
sleep 10
php开发者_Go百科 wes4.php &
sleep 10
php wes5.php &

However I keep receiving messages from the script so I want to keep the scripts working in the background but also stop the alerts/messages that result from executing .


You can redirect output and errors to /dev/null.

php wes.php > /dev/null 2>&1


I miss the simplest solution here: use nohup yourscript.sh &

nohup will make sure, that there are no handlers to the terminal are left open.


Redirect the output somewhere:

php wes.php > somewhere.txt &


Use screen


for i in '' 1 2 3 4 5
do
    php wes$i.php >/dev/null 2>&1 &
    sleep 10
done
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜