Timeline for Initiate bash script on shutdown, but not on reboot
Current License: CC BY-SA 3.0
14 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 9, 2017 at 20:07 | comment | added | cgram | I did see that, thanks. I've been tied up and haven't been able to test. I plan to give it a shot tonight or tomorrow. | |
| Jan 9, 2017 at 14:48 | comment | added | brm | @cgram Just a message in case you didn't notice I added something | |
| Jan 8, 2017 at 13:58 | comment | added | brm | After some testing, I came up with another possible solution. Hope this works... | |
| Jan 8, 2017 at 13:57 | history | edited | brm | CC BY-SA 3.0 | added 1807 characters in body |
| Jan 7, 2017 at 19:55 | comment | added | brm | Perhaps you can add some extra ExecStartPre lines to start the necessary network processes again. A clean way would require a better knowledge of systemd than I possess I'm afraid. | |
| Jan 7, 2017 at 16:04 | comment | added | cgram | The plot thickens. I added a line to create a file and write to it...and that part works. So your theory regarding network status may be correct. Any idea how to get around it? | |
| Jan 7, 2017 at 15:36 | comment | added | brm | Hmm, perhaps the shutdown procedure did something to the network status, not allowing you to run ssh successfully anymore. In that case, your script is actually executed, but because ssh doesn't work correctly anymore (and takes a while to notice this), the shutdown seems to hang. Could you try adding a line above the ssh command that writes something to a file, to see if it is executed? That works in my VM... | |
| Jan 7, 2017 at 15:24 | comment | added | cgram | And just for comparison, I commented out the ExecStartPre command in both services, and entered 'sudo shutdown now', and the box powered down normally. So, there does seem to be something about the ExecStartPre line that's causing issues. | |
| Jan 7, 2017 at 15:21 | comment | added | cgram | Thanks for helping out, brm...but still no luck. I've added the ExecStartPre line to both systemd-shutdown.service and systemd-halt.service. However, each time I enter "sudo shutdown now", it stops at the "Reached target Shutdown" message and never powers off. It also does not execute the pfsenseshutdown script. I did notice that the status of the halt and shutdown services says "Active: inactive (dead)"...but I'm not sure if that matters or not. Any other advice? | |
| Jan 7, 2017 at 13:07 | comment | added | brm | I did some more experiments and made a slight addition to the answer (about editing systemd-halt.service as well). Can you try again? | |
| Jan 7, 2017 at 13:04 | history | edited | brm | CC BY-SA 3.0 | added 167 characters in body |
| Jan 7, 2017 at 12:42 | comment | added | brm | Maybe there's a difference in how the shutdown is initiated? I'm testing using a virtual machine, and if I just type 'halt' at the command line, I get the same behavior that you mention: the "Reached target Shutdown" message is shown, but the script is not executed and the VM doesn't really power off. On the other hand, I can also initiate shutdown by selecting "shutdown" in the GUI, and then the script is executed and the system powers off | |
| Jan 6, 2017 at 19:49 | comment | added | cgram | No dice. I edited the systemd-poweroff.service to include the ExecStartPre command, but it's not executing the script. Actually...the linux box is halting at the "Reached target Shutdown", and will not actually power off. I know the script path works, because if works fine in original systemd service. Is there a way to shutdown more verbosely to see what it's choking on? | |
| Jan 6, 2017 at 18:30 | history | answered | brm | CC BY-SA 3.0 |