RaspberryPi and reboot and shutdown
brunosso opened this issue · comments
Hi i really like this tool!!!
I fix the issue on Rpi that shows shutdown time in years! Now i want to ask if is possible to fix (or it is normal) the problem of shows every reboot as bad shutdown.
I have an update script run by crontab every 10 days:
#!/bin/bash -e
TODAY=$(date +"%d/%m/%Y %T")
echo ""
echo "###"
echo "### Aggiornamento AVVIATO"
echo "###"
echo "### Ora di inizio: "
echo "### "$TODAY""
echo "###"
echo ""/usr/bin/sudo apt-get update
echo ""
/usr/bin/sudo apt-get -y dist-upgrade
echo ""
#/usr/bin/sudo rpi-update
/usr/bin/sudo tuptimeecho ""
TODAY2=$(date +"%d/%m/%Y %T")
echo ""
echo "###"
echo "### Aggiornamento COMPLETATO"
echo "###"
echo "### Ora di fine: "
echo "### "$TODAY2""
echo "###"
echo ""/usr/bin/sudo shutdown -r now
i use the calling /usr/bin/sudo tuptime
because i send via mail the output of entire script to a log file.
Hi brunosso,
Maybe it's related to the execution of the init script or systemd unit at shutdown.
Please, can you check if that is installed correctly?
Thanks.
I think the problem is on the service...
I edit the /lib/systemd/system/tuptime.service
file to fix the datetime in single board pc like rpi also like suggested in manual (https://github.com/rfrail3/tuptime/blob/dev/tuptime-manual.txt#L568)
● tuptime.service - Tuptime service
Loaded: loaded (/lib/systemd/system/tuptime.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2017-10-26 16:00:00 CEST; 1min 29s ago
Process: 409 ExecStartPre=/usr/bin/sudo ntpdate pool.ntp.org (code=exited, status=1/FAILURE)
ott 26 16:00:00 raspberrypi systemd[1]: Starting Tuptime service...
ott 26 16:00:00 raspberrypi sudo[409]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/ntpdate pool.ntp.org
ott 26 16:00:00 raspberrypi sudo[409]: pam_unix(sudo:session): session opened for user root by (uid=0)
ott 26 16:00:00 raspberrypi sudo[409]: Exiting, name server cannot be used: Temporary failure in name resolution (-3)26 Oct 16:00:00 ntpdate[452]: name server cannot be used: Temporary failure in name resolution
ott 26 16:00:00 raspberrypi sudo[409]: pam_unix(sudo:session): session closed for user root
ott 26 16:00:00 raspberrypi systemd[1]: tuptime.service: Control process exited, code=exited status=1
ott 26 16:00:00 raspberrypi systemd[1]: Failed to start Tuptime service.
ott 26 16:00:00 raspberrypi systemd[1]: tuptime.service: Unit entered failed state.
ott 26 16:00:00 raspberrypi systemd[1]: tuptime.service: Failed with result 'exit-code'.
this is my service file
[Unit]
Description=Tuptime service
[Service]
Type=oneshot
User=root
RemainAfterExit=true
ExecStartPre=/usr/bin/sudo ntpdate pool.ntp.org
ExecStart=/usr/bin/tuptime -x
ExecStop=/usr/bin/tuptime -xg
[Install]
WantedBy=basic.target
i try to install ntp service...
I think for now is fixed... I install the ntp service and edited the tuptime services like this
[Unit]
Description=Tuptime service
After=ntp.service
Requires=ntp.service
[Service]
Type=oneshot
User=root
RemainAfterExit=true
ExecStart=/usr/bin/tuptime -x
ExecStop=/usr/bin/tuptime -xg
[Install]
WantedBy=basic.target
Perfect, thanks for share the workaround 👍