Sample Header Ad - 728x90

Running script at shutdown and reboot to prevent chromium session loss

1 vote
1 answer
1549 views
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!
Asked by istir (11 rep)
Aug 7, 2018, 07:10 PM
Last activity: Feb 22, 2023, 11:08 PM