Tag Archives: NOHUP

How get program name that produced an IO error redirected to a LOG in a nohup command?

By enriquegm82

Good afternoon,

I’m have program that executes in background another programs. The main program would be programA and the programs executed by the main one, would be program1a, program1b and program1c.

I need the programs to continue the execution no matter if the shell connection is lost, so I’m using the NOHUP command.

However, each program has its own LOG file, like follows.-

programA –> logfileA.txt
program1a –> logfile1a.txt
program1b –> logfile1b.txt
program1c –> logfile1c.txt

When an error occurs in one of the child programs, the error message is displayed in the LOG file corresponding to the main program.

Example.-

1) The programA is invoked from another routine.-

nohup nice -10 programA 2>&1 > logfileA.txt

2) Inside programA it invokes the other 3 programs.-

nohup nice -10 program1a 2>&1 > logfile1a.txt
nohup nice -10 program1b 2>&1 > logfile1b.txt
nohup nice -10 program1c 2>&1 > logfile1c.txt

When an error occurs, it is showed or displayed in the logfileA.txt, instead of being displayed in the logfile1a.txt or logfile1b.txt or logfile1c.txt

How can I know what program produced the error that it is displayed in the main program’s LOG file?

Thanks in advance for your responses.

Source: FULL ARTICLE at The UNIX and Linux Forums