I have two Raspberry Pi 3 Model B+.
There is a difference in operation and I would like to know the cause.
Is there anyone who understands?

■Raspai 1
1) Set cron to shut down at the same time every day
2) When that time comes, cron shuts down (first time)
3) After shutting down, turn on the power of the Raspberry Pi and restart it (first time)
4) Sometimes it shuts down (second time) immediately after startup (within 1 minute) (probability is about half and half)
5) Starting Razpai (second time) and looking at the syslog shows that the first start has started at the time of the first shutdown (this is a common operation regardless of the presence or absence of the second shutdown. The clock has stopped until it starts up.) Only when the second shutdown occurs, the shutdown cron is running before synchronizing the time with NTP.

■Raspai 2
1), 2) and 3) are the same.
4) I have never seen a shutdown immediately after booting like the Raspberry 1

■ I want to know
What is the difference between Rasppies that shut down immediately after startup and those that do not?
(What are the factors?)

I'm worried if Razpi 2 will shut down in the future, so if I don't shut it down in the future, I'd like to know the mechanism and feel secure.
(I'm more eager to know the mechanism than the measures for Razpai 1.)

Difference in environment

Both versions of raspbian are 9.4 (stretch), with the following differences.

■Raspai 1
The image of raspbian OS is downloaded from the following site and used.

[email protected]:~ $uname -a
Linux raspberrypi 4.14.79-v7+ #1159 SMP Sun Nov 4 17:50:20 GMT 2018 armv7l GNU/Linux

■Raspai 2
I am using the raspbian OS built with NOOBS that was in the purchased SD card.

[email protected]:~ $uname -a
Linux raspberrypi 4.14.71-v7+ #1145 SMP Fri Sep 21 15:38:35 BST 2018 armv7l GNU/Linux

Applicable source code

The description of shutdown in crontab is as follows.

25 4 * * * sudo shutdown -h now

What I tried

If the Raspberry Pi 1 is not connected to the network, time synchronization will not be possible, so it may occur.

It does not always occur.
Immediately after startup, 1 minute may elapse (next minute) without shutting down.
(I may have shut down immediately after startup, but I don't remember)

What cron does not know

It seems that cron runs once a minute, but once it starts, remember this, and is there a mechanism to prevent it from starting again? I thought. Thanks to this, "Raspai 2" has not shut down the second time, and "Raspai 1" does not have a mechanism that does not start up due to something.

  • Answer # 1

    It's not self-solving, but I'm closing in on this question because the cause is visible.

    [Assumed cause]
    Only Razpi 2 had third-party tools installed. I created a new environment where only the tools were installed, and compared the operations, and the differences appeared.

    Thank you to everyone who cooperated.

  • Answer # 2

    If you record the current time at the time of shutdown and log it out, you can understand something.
    I think that there is no use in thinking about it.

  • Answer # 3

    If the Raspberry Pi 1 is not connected to the network, time synchronization will not be possible, so it may occur.

    With PCs and servers, the hardware clock keeps running even when the power is off. Isn't that the way it works?
    In that case, I think that there is no choice but to delay the startup of crond until after time synchronization.

  • Answer # 4


    I confirmed with the latest buster based one,
    Raspai isfake-hwclockService (/lib/systemd/system/fake-hwclock.service),
    At shutdown and every hour (/etc/cron.hourly/fake-hwclock),
    It is designed to save the current time and set the saved time at startup.

    Execution example

    [email protected]:~ $cat /etc/fake-hwclock.data # Saved data
    2020-06-26 09:12:38
    [email protected]:~ $

    So it may be related to cron execution.
    Wait 65 seconds (after 1 minute) =>What about shutting down?

    % sudo crontab -e

    25 4 * * * sudo bash -c'sleep 65;sudo shutdown -h now'