Problem - create log file

I need to create shell script (check system ) to display the output to the console and write these output to a log file at the same time.

My shell script is like that

Main() {
....
....
}
Main

It takes about 30s to display all the output to the console.

Then I put this command to the last line of the script to capture log

Main >> sys_check.log

The problem is : after the output is displayed to the console, the script takes another 30s to write the output to the log file ( so I have to wait 30s to get back to shell )
Is there any solutions to do all these works in only 30s

Main | tee sys_check.log
1 Like

"tee" delete the old logs.
I need to capture log day by day.

Main | tee -a sys_check.log

There's always a way. start looking at the man pages as the very first task

1 Like

Thanks guys.
Done :):):slight_smile: