Thanks thom's comment and thank you all.
I have found the solution of this issue.
Need add following code at the begining of clilogging.sh
trap "" HUP
The meaning of code is to handle SIGHUP signal, here I ignore this signal, then clilogging.sh
will not quit immediately and have the chance to handle all buffer.
man 7 signal
Signal Value Action Comment
-------------------------------------------------------------------------
SIGHUP 1 Term Hangup detected on controlling terminal
or death of controlling process