How does mongodb exit safely every time it shuts down

  mongodb, question

I develop programs and install mongodb on my own machine, but the problem I often encounter is that the switch is turned on and off every day. Within a few days, mongodb will not start automatically. Then I will check it. It is mostly because mongodb did not exit safely, resulting in deadlock.

Is there any way to cure the old deadlock?

Thank you

If it is Linux, refer to the script starting with k under /etc/rc*.d, init will call it automatically when shutdown.

Windows, you can add a shutdown command in the group policy editor.