Running script at shutdown and reboot to prevent chromium session loss
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm running Ubuntu 18.04.1 and I'm trying to create a script that shuts down Chromium properly before shutting down the system so that it doesn't give me "restore session" popup after booting. I figured I'll use killall to this and came up with/home/shutdownscript.sh
:
#!/bin/bash
killall -HUP "chromium-browser --enable-pinch"
that seems to do the trick.
However, now I have a problem with actually running this script at shutdown or reboot.
First thing I tried was putting it in /etc/init.d
as shutdownscript
with chmod +x
and then symlinking it to rc0.d
and rc6.d
as K99shutdownscript
and later K01ashutdownscript
. However, that didn't work for me.
I thought maybe I should just create a new systemd service, so I created shutdownscript.service
in /etc/systemd/system
with contents like this:
[Unit]
Description=Saves Chromium session
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
ExecStop=/home/istir/shutdownscript.sh
[Install]
WantedBy=multi-user.target
Then I ran systemctl start shutdownscript.service
and systemctl enable shutdownscript.service
but it still didn't work as intended.
The solution is probably very simple but I returned to Linux after around 6 years of using Windows and macOS so I don't really remember what did I do earlier to make shutdown scripts.
Thanks for any help!
systemd shutdown reboot runlevel systemctl
add a comment |Â
up vote
0
down vote
favorite
I'm running Ubuntu 18.04.1 and I'm trying to create a script that shuts down Chromium properly before shutting down the system so that it doesn't give me "restore session" popup after booting. I figured I'll use killall to this and came up with/home/shutdownscript.sh
:
#!/bin/bash
killall -HUP "chromium-browser --enable-pinch"
that seems to do the trick.
However, now I have a problem with actually running this script at shutdown or reboot.
First thing I tried was putting it in /etc/init.d
as shutdownscript
with chmod +x
and then symlinking it to rc0.d
and rc6.d
as K99shutdownscript
and later K01ashutdownscript
. However, that didn't work for me.
I thought maybe I should just create a new systemd service, so I created shutdownscript.service
in /etc/systemd/system
with contents like this:
[Unit]
Description=Saves Chromium session
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
ExecStop=/home/istir/shutdownscript.sh
[Install]
WantedBy=multi-user.target
Then I ran systemctl start shutdownscript.service
and systemctl enable shutdownscript.service
but it still didn't work as intended.
The solution is probably very simple but I returned to Linux after around 6 years of using Windows and macOS so I don't really remember what did I do earlier to make shutdown scripts.
Thanks for any help!
systemd shutdown reboot runlevel systemctl
I would swear it happens by default with Firefox and Chrome in Linux.
â Rui F Ribeiro
Aug 7 at 19:38
I guess it should but for me it doesn't even on fresh installation with only Chromium installed. When I close chromium normally and then reboot everything is as it should, but if I leave chromium open and reboot then it tells me to restore session. It's not critical, just kinda pain to do every time.
â istir
Aug 7 at 19:41
Instead of working around it, I suggest you look into the original issue of Chromium not shutting down properly on reboot. (It should!) Maybe start with this question which might have some ideas of what to try already. Otherwise, try to give more details about which desktop environment and/or window manager are you using, where you installed Chromium from, how you're rebooting the machine, etc. to troubleshoot that. I suggest asking a new question (as this one is about other stuff.) Maybe consider asking at AskUbuntu, might get more answers there.
â Filipe Brandenburger
Aug 8 at 2:08
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm running Ubuntu 18.04.1 and I'm trying to create a script that shuts down Chromium properly before shutting down the system so that it doesn't give me "restore session" popup after booting. I figured I'll use killall to this and came up with/home/shutdownscript.sh
:
#!/bin/bash
killall -HUP "chromium-browser --enable-pinch"
that seems to do the trick.
However, now I have a problem with actually running this script at shutdown or reboot.
First thing I tried was putting it in /etc/init.d
as shutdownscript
with chmod +x
and then symlinking it to rc0.d
and rc6.d
as K99shutdownscript
and later K01ashutdownscript
. However, that didn't work for me.
I thought maybe I should just create a new systemd service, so I created shutdownscript.service
in /etc/systemd/system
with contents like this:
[Unit]
Description=Saves Chromium session
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
ExecStop=/home/istir/shutdownscript.sh
[Install]
WantedBy=multi-user.target
Then I ran systemctl start shutdownscript.service
and systemctl enable shutdownscript.service
but it still didn't work as intended.
The solution is probably very simple but I returned to Linux after around 6 years of using Windows and macOS so I don't really remember what did I do earlier to make shutdown scripts.
Thanks for any help!
systemd shutdown reboot runlevel systemctl
I'm running Ubuntu 18.04.1 and I'm trying to create a script that shuts down Chromium properly before shutting down the system so that it doesn't give me "restore session" popup after booting. I figured I'll use killall to this and came up with/home/shutdownscript.sh
:
#!/bin/bash
killall -HUP "chromium-browser --enable-pinch"
that seems to do the trick.
However, now I have a problem with actually running this script at shutdown or reboot.
First thing I tried was putting it in /etc/init.d
as shutdownscript
with chmod +x
and then symlinking it to rc0.d
and rc6.d
as K99shutdownscript
and later K01ashutdownscript
. However, that didn't work for me.
I thought maybe I should just create a new systemd service, so I created shutdownscript.service
in /etc/systemd/system
with contents like this:
[Unit]
Description=Saves Chromium session
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
ExecStop=/home/istir/shutdownscript.sh
[Install]
WantedBy=multi-user.target
Then I ran systemctl start shutdownscript.service
and systemctl enable shutdownscript.service
but it still didn't work as intended.
The solution is probably very simple but I returned to Linux after around 6 years of using Windows and macOS so I don't really remember what did I do earlier to make shutdown scripts.
Thanks for any help!
systemd shutdown reboot runlevel systemctl
systemd shutdown reboot runlevel systemctl
edited Aug 7 at 20:17
asked Aug 7 at 19:10
istir
11
11
I would swear it happens by default with Firefox and Chrome in Linux.
â Rui F Ribeiro
Aug 7 at 19:38
I guess it should but for me it doesn't even on fresh installation with only Chromium installed. When I close chromium normally and then reboot everything is as it should, but if I leave chromium open and reboot then it tells me to restore session. It's not critical, just kinda pain to do every time.
â istir
Aug 7 at 19:41
Instead of working around it, I suggest you look into the original issue of Chromium not shutting down properly on reboot. (It should!) Maybe start with this question which might have some ideas of what to try already. Otherwise, try to give more details about which desktop environment and/or window manager are you using, where you installed Chromium from, how you're rebooting the machine, etc. to troubleshoot that. I suggest asking a new question (as this one is about other stuff.) Maybe consider asking at AskUbuntu, might get more answers there.
â Filipe Brandenburger
Aug 8 at 2:08
add a comment |Â
I would swear it happens by default with Firefox and Chrome in Linux.
â Rui F Ribeiro
Aug 7 at 19:38
I guess it should but for me it doesn't even on fresh installation with only Chromium installed. When I close chromium normally and then reboot everything is as it should, but if I leave chromium open and reboot then it tells me to restore session. It's not critical, just kinda pain to do every time.
â istir
Aug 7 at 19:41
Instead of working around it, I suggest you look into the original issue of Chromium not shutting down properly on reboot. (It should!) Maybe start with this question which might have some ideas of what to try already. Otherwise, try to give more details about which desktop environment and/or window manager are you using, where you installed Chromium from, how you're rebooting the machine, etc. to troubleshoot that. I suggest asking a new question (as this one is about other stuff.) Maybe consider asking at AskUbuntu, might get more answers there.
â Filipe Brandenburger
Aug 8 at 2:08
I would swear it happens by default with Firefox and Chrome in Linux.
â Rui F Ribeiro
Aug 7 at 19:38
I would swear it happens by default with Firefox and Chrome in Linux.
â Rui F Ribeiro
Aug 7 at 19:38
I guess it should but for me it doesn't even on fresh installation with only Chromium installed. When I close chromium normally and then reboot everything is as it should, but if I leave chromium open and reboot then it tells me to restore session. It's not critical, just kinda pain to do every time.
â istir
Aug 7 at 19:41
I guess it should but for me it doesn't even on fresh installation with only Chromium installed. When I close chromium normally and then reboot everything is as it should, but if I leave chromium open and reboot then it tells me to restore session. It's not critical, just kinda pain to do every time.
â istir
Aug 7 at 19:41
Instead of working around it, I suggest you look into the original issue of Chromium not shutting down properly on reboot. (It should!) Maybe start with this question which might have some ideas of what to try already. Otherwise, try to give more details about which desktop environment and/or window manager are you using, where you installed Chromium from, how you're rebooting the machine, etc. to troubleshoot that. I suggest asking a new question (as this one is about other stuff.) Maybe consider asking at AskUbuntu, might get more answers there.
â Filipe Brandenburger
Aug 8 at 2:08
Instead of working around it, I suggest you look into the original issue of Chromium not shutting down properly on reboot. (It should!) Maybe start with this question which might have some ideas of what to try already. Otherwise, try to give more details about which desktop environment and/or window manager are you using, where you installed Chromium from, how you're rebooting the machine, etc. to troubleshoot that. I suggest asking a new question (as this one is about other stuff.) Maybe consider asking at AskUbuntu, might get more answers there.
â Filipe Brandenburger
Aug 8 at 2:08
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
With reference to this, we might need to run the following after configuring systemctl.
sudo systemctl daemon-reload
And we should have a header in the script like below.
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start:
# Required-Stop:
# Default-Start: 0 1 6
# Default-Stop:
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
Still no luck, when usingsystemctl enable
it actually gives an errorupdate-rc.d: error: shutdownscript Default-Start contains no runlevels, aborting.
â istir
Aug 7 at 19:47
@istir try the header as updated in the answer.
â msp9011
Aug 7 at 19:59
I succeeded in enabling the script and running it but it still doesn't do what I want it to do. Maybe I should change Default-start to 0 6? IIRC these are numbers for shutdown and reboot. I had to changeshutdownscript.service
toshutdownscriptnew.service
because I couldn't enable it otherwise. However, when runningsudo systemctl stop shutdownscriptnew.service
it actually does what it should and closes chromium.
â istir
Aug 7 at 20:16
yes we should start at run level 0,1 and 6
â msp9011
Aug 7 at 20:20
Still no luck, I tried changing Default-Start and Default-Stop and even ExecStart and ExecStop - if I runsystemctl stop shutdownscriptnew.service
it closes chromium, but if I reboot it doesn't do anything and it still terminates it so that I have to restore session.
â istir
Aug 7 at 20:59
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
With reference to this, we might need to run the following after configuring systemctl.
sudo systemctl daemon-reload
And we should have a header in the script like below.
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start:
# Required-Stop:
# Default-Start: 0 1 6
# Default-Stop:
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
Still no luck, when usingsystemctl enable
it actually gives an errorupdate-rc.d: error: shutdownscript Default-Start contains no runlevels, aborting.
â istir
Aug 7 at 19:47
@istir try the header as updated in the answer.
â msp9011
Aug 7 at 19:59
I succeeded in enabling the script and running it but it still doesn't do what I want it to do. Maybe I should change Default-start to 0 6? IIRC these are numbers for shutdown and reboot. I had to changeshutdownscript.service
toshutdownscriptnew.service
because I couldn't enable it otherwise. However, when runningsudo systemctl stop shutdownscriptnew.service
it actually does what it should and closes chromium.
â istir
Aug 7 at 20:16
yes we should start at run level 0,1 and 6
â msp9011
Aug 7 at 20:20
Still no luck, I tried changing Default-Start and Default-Stop and even ExecStart and ExecStop - if I runsystemctl stop shutdownscriptnew.service
it closes chromium, but if I reboot it doesn't do anything and it still terminates it so that I have to restore session.
â istir
Aug 7 at 20:59
add a comment |Â
up vote
0
down vote
With reference to this, we might need to run the following after configuring systemctl.
sudo systemctl daemon-reload
And we should have a header in the script like below.
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start:
# Required-Stop:
# Default-Start: 0 1 6
# Default-Stop:
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
Still no luck, when usingsystemctl enable
it actually gives an errorupdate-rc.d: error: shutdownscript Default-Start contains no runlevels, aborting.
â istir
Aug 7 at 19:47
@istir try the header as updated in the answer.
â msp9011
Aug 7 at 19:59
I succeeded in enabling the script and running it but it still doesn't do what I want it to do. Maybe I should change Default-start to 0 6? IIRC these are numbers for shutdown and reboot. I had to changeshutdownscript.service
toshutdownscriptnew.service
because I couldn't enable it otherwise. However, when runningsudo systemctl stop shutdownscriptnew.service
it actually does what it should and closes chromium.
â istir
Aug 7 at 20:16
yes we should start at run level 0,1 and 6
â msp9011
Aug 7 at 20:20
Still no luck, I tried changing Default-Start and Default-Stop and even ExecStart and ExecStop - if I runsystemctl stop shutdownscriptnew.service
it closes chromium, but if I reboot it doesn't do anything and it still terminates it so that I have to restore session.
â istir
Aug 7 at 20:59
add a comment |Â
up vote
0
down vote
up vote
0
down vote
With reference to this, we might need to run the following after configuring systemctl.
sudo systemctl daemon-reload
And we should have a header in the script like below.
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start:
# Required-Stop:
# Default-Start: 0 1 6
# Default-Stop:
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
With reference to this, we might need to run the following after configuring systemctl.
sudo systemctl daemon-reload
And we should have a header in the script like below.
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start:
# Required-Stop:
# Default-Start: 0 1 6
# Default-Stop:
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
edited Aug 7 at 20:20
answered Aug 7 at 19:43
msp9011
3,46643862
3,46643862
Still no luck, when usingsystemctl enable
it actually gives an errorupdate-rc.d: error: shutdownscript Default-Start contains no runlevels, aborting.
â istir
Aug 7 at 19:47
@istir try the header as updated in the answer.
â msp9011
Aug 7 at 19:59
I succeeded in enabling the script and running it but it still doesn't do what I want it to do. Maybe I should change Default-start to 0 6? IIRC these are numbers for shutdown and reboot. I had to changeshutdownscript.service
toshutdownscriptnew.service
because I couldn't enable it otherwise. However, when runningsudo systemctl stop shutdownscriptnew.service
it actually does what it should and closes chromium.
â istir
Aug 7 at 20:16
yes we should start at run level 0,1 and 6
â msp9011
Aug 7 at 20:20
Still no luck, I tried changing Default-Start and Default-Stop and even ExecStart and ExecStop - if I runsystemctl stop shutdownscriptnew.service
it closes chromium, but if I reboot it doesn't do anything and it still terminates it so that I have to restore session.
â istir
Aug 7 at 20:59
add a comment |Â
Still no luck, when usingsystemctl enable
it actually gives an errorupdate-rc.d: error: shutdownscript Default-Start contains no runlevels, aborting.
â istir
Aug 7 at 19:47
@istir try the header as updated in the answer.
â msp9011
Aug 7 at 19:59
I succeeded in enabling the script and running it but it still doesn't do what I want it to do. Maybe I should change Default-start to 0 6? IIRC these are numbers for shutdown and reboot. I had to changeshutdownscript.service
toshutdownscriptnew.service
because I couldn't enable it otherwise. However, when runningsudo systemctl stop shutdownscriptnew.service
it actually does what it should and closes chromium.
â istir
Aug 7 at 20:16
yes we should start at run level 0,1 and 6
â msp9011
Aug 7 at 20:20
Still no luck, I tried changing Default-Start and Default-Stop and even ExecStart and ExecStop - if I runsystemctl stop shutdownscriptnew.service
it closes chromium, but if I reboot it doesn't do anything and it still terminates it so that I have to restore session.
â istir
Aug 7 at 20:59
Still no luck, when using
systemctl enable
it actually gives an error update-rc.d: error: shutdownscript Default-Start contains no runlevels, aborting.
â istir
Aug 7 at 19:47
Still no luck, when using
systemctl enable
it actually gives an error update-rc.d: error: shutdownscript Default-Start contains no runlevels, aborting.
â istir
Aug 7 at 19:47
@istir try the header as updated in the answer.
â msp9011
Aug 7 at 19:59
@istir try the header as updated in the answer.
â msp9011
Aug 7 at 19:59
I succeeded in enabling the script and running it but it still doesn't do what I want it to do. Maybe I should change Default-start to 0 6? IIRC these are numbers for shutdown and reboot. I had to change
shutdownscript.service
to shutdownscriptnew.service
because I couldn't enable it otherwise. However, when running sudo systemctl stop shutdownscriptnew.service
it actually does what it should and closes chromium.â istir
Aug 7 at 20:16
I succeeded in enabling the script and running it but it still doesn't do what I want it to do. Maybe I should change Default-start to 0 6? IIRC these are numbers for shutdown and reboot. I had to change
shutdownscript.service
to shutdownscriptnew.service
because I couldn't enable it otherwise. However, when running sudo systemctl stop shutdownscriptnew.service
it actually does what it should and closes chromium.â istir
Aug 7 at 20:16
yes we should start at run level 0,1 and 6
â msp9011
Aug 7 at 20:20
yes we should start at run level 0,1 and 6
â msp9011
Aug 7 at 20:20
Still no luck, I tried changing Default-Start and Default-Stop and even ExecStart and ExecStop - if I run
systemctl stop shutdownscriptnew.service
it closes chromium, but if I reboot it doesn't do anything and it still terminates it so that I have to restore session.â istir
Aug 7 at 20:59
Still no luck, I tried changing Default-Start and Default-Stop and even ExecStart and ExecStop - if I run
systemctl stop shutdownscriptnew.service
it closes chromium, but if I reboot it doesn't do anything and it still terminates it so that I have to restore session.â istir
Aug 7 at 20:59
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f461148%2frunning-script-at-shutdown-and-reboot-to-prevent-chromium-session-loss%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
I would swear it happens by default with Firefox and Chrome in Linux.
â Rui F Ribeiro
Aug 7 at 19:38
I guess it should but for me it doesn't even on fresh installation with only Chromium installed. When I close chromium normally and then reboot everything is as it should, but if I leave chromium open and reboot then it tells me to restore session. It's not critical, just kinda pain to do every time.
â istir
Aug 7 at 19:41
Instead of working around it, I suggest you look into the original issue of Chromium not shutting down properly on reboot. (It should!) Maybe start with this question which might have some ideas of what to try already. Otherwise, try to give more details about which desktop environment and/or window manager are you using, where you installed Chromium from, how you're rebooting the machine, etc. to troubleshoot that. I suggest asking a new question (as this one is about other stuff.) Maybe consider asking at AskUbuntu, might get more answers there.
â Filipe Brandenburger
Aug 8 at 2:08