Handling Stdout&StdErr for background jobs.

Hello Friends,

sorry, i am not very familiar with Unix programming. Could you please help me on this?

We have to start different components from a startup script.

each components are started as below in the background in a startprocess function

$nohup $file $args >>$logFile 2>&1 &

after this the script calls some waiting method and waits in the logfile for some particular string as below

if grep -c "$pattern" $logFile>1; then ....

and go ahead with the next component.

We have now the problem that the background jobs continue writing into the log file even after startup and covering the disk space.
I am looking for a way to redirect the stdout of the background jobs to dev/null immediately after finding the successful start entry in the log.

Thanks in advance,

Alvin

so you are looking for a condition to be redirected to /dev/null?

maybe i'm not following exactly what you are trying to say.
but you can always direct things to /dev/null basically for test condition status (fail/succeed).

such as

grep -w $switch $file1 > /dev/null
        if [ $? != 0 ]
        then
                cleanup
                exit 1
        fi