How Can I conserve my stream redirection when turning off by power button?

it is my shell scripts.

it turns on whenever I power up my jetson board.
(I have no display monitor on my jetson tk1 board.)

#!/bin/sh
#Linux Script for Executing Python Script.(booting)
echo “Hello World!”

#this one is for reset audio system(it collide with something)
#/etc/init.d/pulseaudio restart
pulseaudio -k
sleep 0.4 # 400 miliseconds
pulseaudio --start
sleep 0.4 # 400 miliseconds

#Determine File’s Name
NOW=$(date +“%Y%m%d%H%M%S”)

#Make Text File
python /home/ubuntu/DroneChallenge/ArduRoverGPSLogging.py > $NOW.txt

sleep 0.3

exit 0

as you see, result of ArduRoverGPSLogging.py’s result is saved to $NOW.txt.

I turn off my Jetson Board with my power button.

I followed this instruction.

https://askubuntu.com/questions/461479/how-do-i-get-my-computer-to-shut-down-with-the-power-button

and when I press Power Button, the console program turned off immediately( I think it is force quit)

and no log file is sustained(I mean… $NOW.txt)

only when I press Ctrl+C to terminate console program, log remains.

how can I sustain my log?

This is a duplicate of:
[url]https://devtalk.nvidia.com/default/topic/1021378/jetson-tk1/how-can-i-turn-off-jetson-board-with-button-/[/url]