Amit
Amit

Reputation: 7

nohup - Not printing all logs

I am running two scripts

# Script 1
nohup sh {command} &

and the nohup.out is having all logs in details (for script 1)

# Script 2 
nohup sh {command} > {log_path} 2>&1 &

But nohup.out having only limited log as listed below (for script 2),

## Script2 output
   Shutdown message has been posted to the server.
   Server shutdown may take a while - check logfiles for completion 

How can i generate all logs by using script 2 format in nohup.out itself .

Upvotes: 0

Views: 690

Answers (1)

limaia
limaia

Reputation: 96

If you want to have both files (nohup.out and {log_path}) you can try:

((nohup {command}) > >(tee {log_path}) 2> >(tee {log_path}))>> nohup.out 

the first part of the command line is explained here.

After this, you only have to redirect (append) output to nohup.out.

Upvotes: 1

Related Questions