Reputation: 73444
Based on this site: Shutting down Debian linux machine, I wrote a script to power off a Debian computer. However, I feel it's too brutal, like the power was cut off by an accident or something. What I want is that the script would behave just like a human would normally power off. Is this the case or the script is forcing the computer to power off abnormally?
#!/bin/bash
sudo poweroff
Why am I worried? Because when I run the script, the computer powers off immediately, while where you are choosing power off from the GUI it takes some time to complete the process of powering off.
In other words the question is:
Is it equivalent to pressing the power button of computer's power or is it quivalnet to selecting power off from the GUI environment?
/etc/init.d
shows a list of programs, like sudo, but powerpff is not listed there.
/etc/rc.local
does this:
exit 0
is this better? Or maybe a combination of exit
and poweroff
would be better?
Upvotes: 0
Views: 281
Reputation: 283
poweroff
is ok from my point of view. I usually switch off the computer like that. It will (as mentioned) end correctly the running services and syncs the disks. It is not at all like hardware unplug. If you have something running, instalation, updates... everything gets a kill signal and you loose your work. Same with GUI programs.
If you want to protect some running programs against poweroff, you must elaborate on the script.
poweroff
and halt
are the links to reboot
. reboot
with -f
reboots by itself, else (i.e. typically) it calls shutdown
tool (seeman reboot
). This means that anyway, in most cases, you always end up with shutdown
call.
Upvotes: 1