Skip to content

Shutting down too fast?

Everytime I shutdown/reboot my computer, my Chromium dies (asks me if I want to restore the last session) so I've been trying to set up a shutdown script which gracefully kills it instead. I've read some guides online with the usual Before=shutdown.target etc but I can't get it to work. Can someone please post a service file which works for them?

My current theory is that Arch shuts down "too fast". I have used Linux Desktops before, and although their shutdown was way faster than Windows', it wasn't quite as instantaneous as it is now.

32 points20 comments
Open on Reddit
About this post
Posted
Archived
Score
32 · 90% up
Kind
Text
ID
vy88ja

Author

4
posts
11
comments
0
media
View profile

22 comments

If I shutdown without closing browsers on Fedora, I get the same restore question on startup. So it's not just Arch, or nothing to do with speed. Probably browsers just handling the quit signal poorly (don't remember which signal that is exactly).

Maybe related to the "are you sure you want to close X tabs" popup? The OS tells the browser to quit, and the browsers asks about closing tabs, and eventually gets killed forcefully because the first graceful signal did not work?

50 points

Chromium doesn't ask, it just closes. But if I shutdown gedit for example, it does ask me if I would like to save any open files before closing. But even then, I can gracefully kill Chromium with pkill -2, I just haven't found a way to run that before shutdown yet.

13 points

You can alias the shutdown command to do so, unless you are using physician buttons or some menu.

7 points

I just remembered that there's an AUR package called chrome-shutdown-hook that closes Chrome/Chromium gracefully on logout, but judging from the comments this is not an issue anymore. Try resetting your profile and disabling extensions as per the comments: https://aur.archlinux.org/packages/chrome-shutdown-hook

If you want to do the systemd service, it should work by having ExecStart do something like sleep inf, and ExecStop doing the actual quitting of Chromium.

2 points

Okay, so turns out that the systemd service did work; I just must've gotten super unlucky. After some testing I've concluded that it doesn't always work, and that SIGTERM works better than SIGINT. So this is all you need (works for logout, shutdown and reboot):

[Unit]
Description=Kills processes gracefully
DefaultDependencies=no
Before=shutdown.target

[Service]
Type=oneshot
ExecStart=/usr/bin/pkill -SIGTERM chromium

[Install]
WantedBy=shutdown.target
20 points

it works well from terminal, but from gnome-shell, it doesn't seem to be working for me.

Jul 15 12:00:38  systemd[1]: Starting Kills chromium gracefully....
Jul 15 12:00:38  systemd[1]: clean-chromium-shutdown.service: Main process exited, code=exited, status=1/FAILURE
Jul 15 12:00:38  systemd[1]: clean-chromium-shutdown.service: Failed with result 'exit-code'.

this is same log as when I start service manually without chromium running.

1 points
unknown author2 hidden

Deleted before we saved it.

6 points

Yeah but when you kill the application gracefully, it doesn't ask you to restore the last session. It just loads it.

5 points
unknown author

Deleted before we saved it.

4 points

I have opposite problem. does anyone know how I can ask chrome to restore the last session automatically on start? I don't want to click on yes every time. Yes, I have finally dedicated some ram for chromium.

1 points

Yeah, use my shutdown service. That gets run before the actual shutdown happens, and shuts down Chromium "softly". That way it doesn't even ask you to restore the session, it just does so automatically.

0 points

omg, didn't realize thanks earlier. Thanks OP OP. Either way - if user wants a restored chrome or a clean chrome, it is a good behavior. imho sigterm should be how shutdown is performed. afaik it waits for like 60 seconds or more for systemd services to gracefully stop, but applications are thrashed instantly.

1 points

on more digging I think this is the issue: https://unix.stackexchange.com/questions/122590/graceful-shutdown-in-archlinux .

check TimeoutStopSec here: https://www.freedesktop.org/software/systemd/man/systemd.service.html

Systemd does not give gdm much time, but I wonder even if it did. what signal gdm would send anyway.

More I think about it, I feel from applications view, existing shut down is like just pulling the power cable. well, atleast systemd stuff like file systems exit properly. so it is not that bad. user apps are pretty much fucked.

1 points

another thing, it might not be systemd completely at fault here. it is the window manager (gnome/x11 in my case) that finally tells systemd to start shutdown systemd's services when we call shutdown). but the behavior must be coherent from both shell and ui.

1 points

This is a feature, not a bug. Why do you think it's a problem?

-9 points

It would appear to be a bug. I've done no special configuration for Chromium or shutting down, but Chromium stops gracefully and does not ask to restore tabs if I shut down my PC. I can confirm that I've not disabled that feature in Chromium and it is working properly. If I pkill -9 chromium or kill the power to my PC then it will prompt me to restore tabs.

Either I have a bug because Chromium stops gracefully before shutting down, or OP has a bug because it doesn't ¯\_(ツ)_/¯

8 points

Hm, I just assumed that all Chromiums are the same, but maybe it's because I use ungoogled-chromium? Anyway, it works with the shutdown script now, so I don't care ;)

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.