I have a python-script that is started at bootup-time as a cronjob to collect measurement-data:
@reboot python /path/to/my_script.py
The Linux-machine is rebooted daily at a certain time as a cronjob:
57 23 * * * sudo reboot
At the time of the reboot I would still have measurement-data that has not been saved yet and which needs to be transferred to a website which may take a couple of seconds. From what I see the reboot- or the shutdown-command would give some advance-warning for gracefully shutting down, however I have not found a way to catch that.
Up to now I was experimenting with signal.SIGTERM, signal.SIGHUP
but these don't cut it and don't react to the shutdown-command. Also trying with nohup did not yield the desired result.
Any advice on how to detect the time before shutdown in that Python-script? Cheers ye_ol_man