SOLVED Proper Shutdown of system

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
egor3f

SOLVED Proper Shutdown of system

Post by egor3f »

Hello, friends! I have a trouble with system shutdown. So, imagine I have 3 programs opened: double commander, firefox and spotify. If i close them (with upper top cross button) and then reopen,
in double commander and firefox all tabs are saved, and in spotify last played track is saved.
But if I shut down system with usual Menu -> Shutdown -> Shutdown, programs are not closed properly! When I then start my computer again, Firefox says that session was suddenly interrupted (and asks if I need to restore tabs), path in double commander is not saved, spotify does not show last track.

SO I NEED to close all programs with "close" button with my mouse, each time, before i shut down my computer.
How to solve this problem? I have: linux mint 18.2 with cinnamon, AMD64, all updates. I have this problem all the time after i have installed mint.

Sorry for my English, I am not native speaker. :)
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
Termy
Level 12
Level 12
Posts: 4248
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Proper Shutdown of system

Post by Termy »

Hi,

First off, your English is good. :)

You might want to post the output of: inxi -Fz
I'm also Terminalforlife on GitHub.
egor3f

Re: Proper Shutdown of system

Post by egor3f »

Thanks for your reply! This is the output:

Code: Select all

System:    Host: EgorMintPC Kernel: 4.10.0-40-generic x86_64 (64 bit) Desktop: Cinnamon 3.4.6
           Distro: Linux Mint 18.2 Sonya
Machine:   System: Gigabyte product: N/A
           Mobo: Gigabyte model: F2A88XM-DS2 v: x.x Bios: American Megatrends v: F7 date: 06/24/2014
CPU:       Quad core AMD Athlon X4 860K (-MCP-) cache: 8192 KB 
           clock speeds: max: 3700 MHz 1: 2400 MHz 2: 2400 MHz 3: 3000 MHz 4: 2400 MHz
Graphics:  Card: NVIDIA GM206 [GeForce GTX 950]
           Display Server: X.Org 1.18.4 drivers: nvidia (unloaded: fbdev,vesa,nouveau)
           Resolution: 1680x1050@59.88hz
           GLX Renderer: GeForce GTX 950/PCIe/SSE2 GLX Version: 4.5.0 NVIDIA 384.90
Audio:     Card-1 Advanced Micro Devices [AMD] FCH Azalia Controller driver: snd_hda_intel
           Card-2 NVIDIA Device 0fba driver: snd_hda_intel
           Sound: Advanced Linux Sound Architecture v: k4.10.0-40-generic
Network:   Card: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller driver: r8169
           IF: enp2s0 state: up speed: 100 Mbps duplex: full mac: <filter>
Drives:    HDD Total Size: 1240.3GB (49.5% used) ID-1: /dev/sda model: WDC_WD10EFRX size: 1000.2GB
           ID-2: /dev/sdb model: SSD_Smartbuy_120 size: 120.0GB
           ID-3: /dev/sdc model: KINGSTON_SHFS37A size: 120.0GB
Partition: ID-1: / size: 22G used: 11G (50%) fs: ext4 dev: /dev/sdb2
           ID-2: /home size: 72G used: 55G (80%) fs: ext4 dev: /dev/sdb5
           ID-3: swap-1 size: 8.10GB used: 0.00GB (0%) fs: swap dev: /dev/sdb1
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
Sensors:   System Temperatures: cpu: 16.0C mobo: N/A gpu: 30C
           Fan Speeds (in rpm): cpu: N/A
Info:      Processes: 222 Uptime: 1:22 Memory: 2493.6/7918.1MB Client: Shell (bash) inxi: 2.2.35 
User avatar
Termy
Level 12
Level 12
Posts: 4248
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Proper Shutdown of system

Post by Termy »

If it were me, I think the first thing I'd try is to reboot the machine via the terminal: reboot

Does it do the same thing?

I'd then consider running pkill -u $USER which will close all the programs under your username, and it won't prompt, to see if it's specifically the reboot, or if it's something about the session not closing out properly.

I'd also wanna see some log files, but I can't think of anything off-hand which shows info specifically about logging out or shutting down. I know of /var/log/boot.log, but that's for starting the machine. Maybe /var/log/syslog can show something useful; take a note of the time you reboot, then have a look at the syslog, perhaps even copy paste a few relavent lines here. Maybe there's something somewhere in the logs which point to the problem.
I'm also Terminalforlife on GitHub.
egor3f

Re: Proper Shutdown of system

Post by egor3f »

reboot and pkill -u $USER produce absolutely the same behaviour — not proper exit of programs like FF or Double commander.
There is the part of syslog after I type pkill:

Code: Select all

Nov 22 17:59:25 EgorMintPC systemd[4164]: Reached target Shutdown.
Nov 22 17:59:25 EgorMintPC systemd[4164]: Stopped target Default.
Nov 22 17:59:25 EgorMintPC systemd[4164]: Starting Exit the Session...
Nov 22 17:59:25 EgorMintPC systemd[4164]: Stopped target Basic System.
Nov 22 17:59:25 EgorMintPC systemd[4164]: Stopped target Sockets.
Nov 22 17:59:25 EgorMintPC systemd[4164]: Stopped target Paths.
Nov 22 17:59:25 EgorMintPC systemd[4164]: Stopped target Timers.
Nov 22 17:59:25 EgorMintPC obexd[4483]: Terminating
Nov 22 17:59:25 EgorMintPC systemd[4164]: Received SIGRTMIN+24 from PID 5003 (kill).
Nov 22 17:59:26 EgorMintPC kernel: [  214.967876] nvidia-modeset: Freed GPU:0 (GPU-67088ad9-200b-1286-5007-bb2db8d36956) @ PCI:0000:01:00.0
Nov 22 17:59:26 EgorMintPC nvidia-persistenced: Received signal 15
Nov 22 17:59:26 EgorMintPC nvidia-persistenced: Socket closed.
Nov 22 17:59:26 EgorMintPC systemd[1]: Stopping NVIDIA Persistence Daemon...
Nov 22 17:59:26 EgorMintPC nvidia-persistenced: PID file unlocked.
Nov 22 17:59:26 EgorMintPC nvidia-persistenced: PID file closed.
Nov 22 17:59:26 EgorMintPC systemd[1]: Stopped NVIDIA Persistence Daemon.
Nov 22 17:59:26 EgorMintPC nvidia-persistenced: The daemon no longer has permission to remove its runtime data directory /var/run/nvidia-persistenced
Nov 22 17:59:26 EgorMintPC nvidia-persistenced: Shutdown (4086)
Nov 22 17:59:26 EgorMintPC lightdm[1201]: /etc/modprobe.d is not a file
Nov 22 17:59:26 EgorMintPC lightdm[1201]: message repeated 4 times: [ /etc/modprobe.d is not a file]
Nov 22 17:59:26 EgorMintPC lightdm[1201]: Error: can't open /lib/modules/4.10.0-40-generic/updates/dkms
Nov 22 17:59:26 EgorMintPC lightdm[1201]: Error: can't open /lib/modules/4.10.0-40-generic/updates/dkms
Nov 22 17:59:26 EgorMintPC lightdm[1201]: update-alternatives: error: no alternatives for x86_64-linux-gnu_gfxcore_conf
Nov 22 17:59:26 EgorMintPC systemd[1]: Starting NVIDIA Persistence Daemon...
Nov 22 17:59:26 EgorMintPC nvidia-persistenced: Verbose syslog connection opened
Nov 22 17:59:26 EgorMintPC nvidia-persistenced: Now running with user ID 122 and group ID 131
Nov 22 17:59:26 EgorMintPC nvidia-persistenced: Started (5042)
Nov 22 17:59:26 EgorMintPC systemd[1]: Started NVIDIA Persistence Daemon.
Nov 22 17:59:26 EgorMintPC nvidia-persistenced: device 0000:01:00.0 - registered
Nov 22 17:59:26 EgorMintPC nvidia-persistenced: Local RPC service initialized
Nov 22 17:59:26 EgorMintPC kernel: [  215.609022] nvidia-modeset: Allocated GPU:0 (GPU-67088ad9-200b-1286-5007-bb2db8d36956) @ PCI:0000:01:00.0
Nov 22 17:59:26 EgorMintPC acpid: client 4080[0:0] has disconnected
Nov 22 17:59:26 EgorMintPC acpid: client connected from 5036[0:0]
Nov 22 17:59:26 EgorMintPC acpid: 1 client rule loaded
Nov 22 17:59:27 EgorMintPC systemd[1]: Started Session c6 of user lightdm.
Nov 22 17:59:27 EgorMintPC /slick-greeter-check-hidpi: Window scale: 1
Nov 22 17:59:27 EgorMintPC /slick-greeter-set-keyboard-layout: Current keyboard configuration: rules:      evdev#012model:      pc105#012layout:     us,ru#012variant:    ,#012options:    grp:alt_shift_toggle,grp_led:scroll
Nov 22 17:59:27 EgorMintPC /slick-greeter-set-keyboard-layout: Applying keyboard configuration: ['setxkbmap', '-model', 'pc105', '-layout', 'us,ru', '-variant', ',', '-option', 'grp:alt_shift_toggle,grp_led:scroll', '-v']
Nov 22 17:59:27 EgorMintPC /slick-greeter-set-keyboard-layout: Result: Warning! Multiple definitions of keyboard model#012         Using command line, ignoring X server#012Warning! Multiple definitions of keyboard layout#012         Using command line, ignoring X server#012Warning! Multiple definitions of layout variant#012         Using command line, ignoring X server#012Trying to build keymap using the following components:#012keycodes:   evdev+aliases(qwerty)#012types:      complete#012compat:     complete+ledscroll(group_lock)#012symbols:    pc+us+ru:2+inet(evdev)+group(alt_shift_toggle)#012geometry:   pc(pc105)
Nov 22 17:59:27 EgorMintPC /slick-greeter-set-keyboard-layout: New keyboard configuration: rules:      evdev#012model:      pc105#012layout:     us,ru#012variant:    ,#012options:    grp:alt_shift_toggle,grp_led:scroll,grp:alt_shift_toggle,grp_led:scroll
Nov 22 17:59:27 EgorMintPC org.a11y.atspi.Registry[5087]: SpiRegistry daemon is running with well-known name - org.a11y.atspi.Registry
Nov 22 17:59:28 EgorMintPC systemd[1]: Stopped User Manager for UID 1000.
Nov 22 17:59:28 EgorMintPC systemd[1]: Removed slice User Slice of egor.
egor3f

Re: Proper Shutdown of system

Post by egor3f »

Even the command pkill firefox leads to the same thing - session recovery window
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Proper Shutdown of system

Post by Flemur »

egor3f wrote:But if I shut down system with usual Menu -> Shutdown -> Shutdown, programs are not closed properly!
I get that also, and, FWIW and AFAIK, none of the "kill" or "pkill" options stop a program "nicely" = the same way as "File->Exit" or clicking the "Exit" button on the titlebar, including: pkill -u $USER
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
egor3f

Re: Proper Shutdown of system

Post by egor3f »

I get that also, and, FWIW and AFAIK, none of the "kill" or "pkill" options stop a program "nicely"
And what can be a solution like? May be, some workaround?
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Proper Shutdown of system

Post by Flemur »

egor3f wrote:
I get that also, and, FWIW and AFAIK, none of the "kill" or "pkill" options stop a program "nicely"
And what can be a solution like? May be, some workaround?
My work-around is to manually close all the programs - well, the ones where it matters - using the programs' GUIs.

FWIW, this doesn't close programs nicely, either:

Code: Select all

/bin/systemctl reboot
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
User avatar
Termy
Level 12
Level 12
Posts: 4248
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Proper Shutdown of system

Post by Termy »

Flemur wrote:
egor3f wrote:But if I shut down system with usual Menu -> Shutdown -> Shutdown, programs are not closed properly!
I get that also, and, FWIW and AFAIK, none of the "kill" or "pkill" options stop a program "nicely" = the same way as "File->Exit" or clicking the "Exit" button on the titlebar, including: pkill -u $USER
It depends on how the program was written with regards to signal handling. It also depends on the signal sent. There are many, with varying levels of "do as I say"ness. xD
I'm also Terminalforlife on GitHub.
egor3f

Re: Proper Shutdown of system

Post by egor3f »

Termy wrote: It depends on how the program was written with regards to signal handling. It also depends on the signal sent. There are many, with varying levels of "do as I say"ness. xD
I've tried different signals in htop kill menu: SIG: INT, TERM, KILL, HUP, PWR... They all stop my browser immediately, and they all lead to session recovery.
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Proper Shutdown of system

Post by Flemur »

Termy wrote: It also depends on the signal sent. There are many, with varying levels of "do as I say"ness. xD
Indeed it does, so perhaps you could suggest a signal which works...on something. Anything.

I've tried many, and so far none work properly.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
User avatar
Termy
Level 12
Level 12
Posts: 4248
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Proper Shutdown of system

Post by Termy »

Flemur wrote:
Termy wrote: It also depends on the signal sent. There are many, with varying levels of "do as I say"ness. xD
Indeed it does, so perhaps you could suggest a signal which works...on something. Anything.

I've tried many, and so far none work properly.
SIGHUP seems to be the cleanest. I've had no real issues out of using SIGINT either (interrupt, like with Ctrl + C). You might find man 7 signal of interest. SIGKILL is going nuclear; it "cannot be caught, blocked, or ignored", so use that with absolute care. Ideally, you want to lean more towards using standard exits and quits in something like a GUI. You can get a list of signals by running kill -l, trap -l, skill -l, killall -l, and various other ways.

Different version of software could also allow for any inconsistencies. I came across somebody on this site who had issues with a couple of signals used on Firefox, yet I have zero issue with it. Bit of a shame it's not entirely consistent, but that's the nature of the beast, I suppose. That said, I haven't tested any signals on the latest Firefox (57, Quantum).
I'm also Terminalforlife on GitHub.
egor3f

Re: Proper Shutdown of system

Post by egor3f »

I have'nt found a solution, so I wrote a small script myself: it's only 6 lines :-)

Code: Select all

#!/bin/bash
WINDOWSLIST=$(wmctrl -l | awk '$2 == 0 {print $1;}')
for window1 in $WINDOWSLIST ; do
wmctrl -c $window1 -i
done
sleep 3
shutdown -h now
It closes all windows properly, I've already tested it. Just add a shortcut to this script to your desktop, and use it instead of shutdown menu.

UPDATE TO POST: Added sleep 3 command to allow all apps close. If some apps doesn't close properly, increase sleep time
egor3f

Re: SOLVED Proper Shutdown of system

Post by egor3f »

Proper icon for this shortcut is located in:
/usr/share/icons/Mint-X/actions/96/xfce-system-exit.svg
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Proper Shutdown of system

Post by Flemur »

egor3f wrote:I have'nt found a solution, so I wrote a small script myself: it's only 6 lines :-)
That DID shut down firefox so that it started normally the next time. (But it didn't close the "wine" windows, or get to the "shutdown" statement.)

Edit: it worked on a wine window by hand...

Code: Select all

$ wmctrl -l 
...
0x01e00004  ... foobar2000 v1.3.10
$ wmctrl -c  0x01e00004  -i
Edit2: It works on "wine" windows - I think the reason it didn't at first was because it killed the terminal I was running it from.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Locked

Return to “Beginner Questions”