Running script at shutdown and reboot to prevent chromium session loss

The name of the pictureThe name of the pictureThe name of the pictureClash 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!










share|improve this question























  • 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














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!










share|improve this question























  • 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












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!










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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
















  • 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










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





share|improve this answer






















  • 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










  • 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










  • 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










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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





share|improve this answer






















  • 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










  • 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










  • 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














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





share|improve this answer






















  • 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










  • 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










  • 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












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





share|improve this answer














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






share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 7 at 20:20

























answered Aug 7 at 19:43









msp9011

3,46643862




3,46643862











  • 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










  • 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










  • 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, 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










  • 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










  • 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, 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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?