2

I want to shutdown computer with my phone using KDE Connect. That can be easily done by adding a shutdown command in the setting of the Runcommand plugin within the KDE Connect program in Linux.

enter image description here

The idea is to close the applications gracefully without abruptly killing them and losing last configurations, for example.

I know about systemctl poweroff.

I read under this question that "shutdown -h now or shutdown -r now are graceful", and also that scripts involved may vary depending on the distribution. What is the situation in Ubuntu?

Are the commands above preferable to systemctl poweroff for my purpose?

1 Answers1

0

A graceful shutdown means that the programs receive a hang up signal (HUP). If the program is developed properly, it will listen to this signal and act accordingly (prepare the program to get shut down, clearing used memory, deleting tmp files, etc.).

It does not really matter, if it is done on the GUI or on the terminal, the HUP signal will be send either way.

This also answers your question if Ubuntu behaves differently then other distros. It does not. The mechanism is the same. An odd behaviour can be expected from programs which don't act properly when they get a HUP signal, but this is because the program does not do it properly, it has nothing to do with the distro.

P.S.:

shutdown -h 

will power off the system, while

shutdown -r

will reboot the system (so this is unusable for you)

Just use shutdown or add -P or --poweroff (but this is the default anyway according to the man page).

s1mmel
  • 2,124