[SOLVED] Automatic Logout

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read how to get help
Post Reply
rjsrjs
Level 3
Level 3
Posts: 154
Joined: Sun Mar 17, 2019 6:47 pm
Location: Florida

[SOLVED] Automatic Logout

Post by rjsrjs »

I hope this is the correct place to post this article, if not please inform me.

I know I can use screensaver to lock the screen and have to enter my password when re-entering the OS. My question, is there a way I can have the computer actually log out after a certain amount of time of no activity? I can log out in the mint menu or by hitting some keyboard keys I have set up. I want Linux Mint 19.1 to "log out" after 90 min of inactivity and return to the regular "log in" screen, when I go and work on the computer.

Hope this is a clear enough explanation of my question :?

Thank you:
Last edited by rjsrjs on Sat Oct 05, 2019 3:12 pm, edited 2 times in total.
User avatar
Pjotr
Level 22
Level 22
Posts: 16682
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: Automatic Logout

Post by Pjotr »

Tip: 10 things to do after installing Linux Mint 20.2 Uma
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
rjsrjs
Level 3
Level 3
Posts: 154
Joined: Sun Mar 17, 2019 6:47 pm
Location: Florida

Re: Automatic Logout

Post by rjsrjs »

Tried your suggested web site Pjotr nothing seemed to work. I wasn't taken to the login page. Xscreensaver only locked the screen, no actual logout, I have to do it manually via menu or keyboard. :(
User avatar
catweazel
Level 19
Level 19
Posts: 9872
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Automatic Logout

Post by catweazel »

rjsrjs wrote:
Fri Oct 04, 2019 5:12 pm
Tried your suggested web site Pjotr nothing seemed to work. I wasn't taken to the login page. Xscreensaver only locked the screen, no actual logout, I have to do it manually via menu or keyboard. :(
I think you need to be a bit more descriptive of what you did and didn't do, what did and what did not occur, and when it did or did not occur. "Nothing seemed to work" is meaningless from a technical perspective, and there is no mention of screensavers of any kind at all on the page that you refer to.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
gm10
Level 20
Level 20
Posts: 10558
Joined: Thu Jun 21, 2018 5:11 pm

Re: Automatic Logout

Post by gm10 »

That suggested link is only for login sessions (e.g. ssh or tty logins), not the desktop environment. Speaking of screensavers though, that would appear to me the simplest way to do this, simply create a screensaver that performs said logout. Since no details about the system were shared I cannot provide implementation details, either. ;)
rjsrjs
Level 3
Level 3
Posts: 154
Joined: Sun Mar 17, 2019 6:47 pm
Location: Florida

Re: Automatic Logout

Post by rjsrjs »

Thanks gm10 and all others, now I understand whats going on. I'm currently running Linux Mint 19.1 MATE DE on a Lenovo T430 with 8 Gigs RAM and a Intel 180 GB SSD. For a screensaver I have Xscreensaver and I removed Mate-screensaver as it was clashing with Xscreensaver. I have Xscreensaver set up to run GLSlideshow of pics I have after 30 min of inactivity. Then after 60 min, power management puts the display to sleep. When I go back on the computer I have it set up to enter my password, which is fine. I was just curious if I could make mint do an actual log out from the desktop automatically after a certain time of inactivity, like when you click on the logout icon in the menu that take you to the login screen.

Sorry I didn't give much information in the first post, hope this post helps more.

Thanks to all:
gm10
Level 20
Level 20
Posts: 10558
Joined: Thu Jun 21, 2018 5:11 pm

Re: Automatic Logout

Post by gm10 »

On MATE, if you can make your screensaver run mate-session-save --force-logout instead you'll be logged off.
rjsrjs
Level 3
Level 3
Posts: 154
Joined: Sun Mar 17, 2019 6:47 pm
Location: Florida

Re: Automatic Logout

Post by rjsrjs »

Thanks gm10 running Xscreensaver with the --force logout command worked perfectly :D . It's not exactly what I want though. I would like to run GLSlideshow first and after say 2 hours of inactivity I would like Mint Mate to log off automatically. Looks like I can't do that though because Xscreensaver only takes one command at a time.

Thanks, really appreciate the info. Now I know what to do if I want to logout automatically.
User avatar
Spearmint2
Level 16
Level 16
Posts: 6927
Joined: Sat May 04, 2013 1:41 pm
Location: Maryland, USA

Re: Automatic Logout

Post by Spearmint2 »

I like gm10's way, it's easy. Maybe something creating a CRON job with the shutdown command would work, so long as there's an opt-out and it resets, for when you are still using computer.

https://www.bing.com/search?q=cron+shut ... orm=OSDSRC
All things go better with Mint. Mint julep, mint jelly, mint gum, candy mints, pillow mints, peppermint, chocolate mints, spearmint,....
rjsrjs
Level 3
Level 3
Posts: 154
Joined: Sun Mar 17, 2019 6:47 pm
Location: Florida

Re: Automatic Logout

Post by rjsrjs »

Instead of "shutdown" I would rather use "logout" so I don't have to restart the computer from scratch.

I already have a cron job in linux Mate 19.1 running "init 0" at 1:30am everyday. which shuts down the computer every morning at 1:30am if I fall asleep and forget to shutdown the laptop.

# m h dom mon dow user command
30 1 * * * root init 0

Thanks:
gm10
Level 20
Level 20
Posts: 10558
Joined: Thu Jun 21, 2018 5:11 pm

Re: Automatic Logout

Post by gm10 »

rjsrjs wrote:
Sat Oct 05, 2019 10:38 am
Thanks gm10 running Xscreensaver with the --force logout command worked perfectly :D . It's not exactly what I want though. I would like to run GLSlideshow first and after say 2 hours of inactivity I would like Mint Mate to log off automatically. Looks like I can't do that though because Xscreensaver only takes one command at a time.
That's easily solved with a script as well:

Code: Select all

timeout 2h GLSlideshow || mate-session-save --force-logout
Replace GLSlideshow for the actual command. Also I don't know how Xscreensaver handles this but you'll likely have to wrap the whole thing in a shell like this:

Code: Select all

bash -c "timeout 2h GLSlideshow || mate-session-save --force-logout"
rjsrjs
Level 3
Level 3
Posts: 154
Joined: Sun Mar 17, 2019 6:47 pm
Location: Florida

Re: Automatic Logout

Post by rjsrjs »

So.. let me try and understand. In order to do what I asked you, I have to use only Xscreensaver and type in the command(s) into Xscreensaver to make this work, right? That's fine, I can do that if needed. So to keep any running programs or data loss that anyone else has running, I think I'll just keep it the way it is for now and just run GLSlideshow activated in 30 min unattended. and let Power Manager blank the screen in 1 hour. That way everything returns as before when returning to the computer to continue working, no surprises.

By the way I am only running one laptop shared with my wife who sometimes uses the laptop without my knowledge. I don't want the laptop logging out if she steps away from working on an important project and loose all her data.

timeout 2h GLSlideshow || mate-session-save --force-logout

Oh I almost forgot, in the --force logout command where is the time in minutes (like 2 hours before logout) to force logout? Is that what the "2h" is for?

Thanks all for the fine information.
gm10
Level 20
Level 20
Posts: 10558
Joined: Thu Jun 21, 2018 5:11 pm

Re: Automatic Logout

Post by gm10 »

Yes, man timeout.

And I'm not trying to convince you to do this, it's what you asked for in making this thread. ;)
DisturbedDragon
Level 4
Level 4
Posts: 238
Joined: Mon Oct 29, 2012 6:29 pm
Location: Texas

Re: Automatic Logout

Post by DisturbedDragon »

Using your favorite editor:

/etc/profile

then add line

TMOUT=xxx

The TMOUT argument is presented in seconds. Save and close.
AMD Ryzen 9 3950X 16C/32T | MSI x470 Gaming Pro | 2TB Mushkin Pilot-E NVMe | 1TB Crucial P1 NVMe | 1TB Samsung 960 Pro NVMe | 32GB DDR4 3200 | Nvidia RTX2080 OC | Linux Mint 20.1 Cinnamon
rjsrjs
Level 3
Level 3
Posts: 154
Joined: Sun Mar 17, 2019 6:47 pm
Location: Florida

Re: Automatic Logout

Post by rjsrjs »

DisturbedDragon wrote:
Sat Oct 05, 2019 1:24 pm
Using your favorite editor:

/etc/profile

then add line

TMOUT=xxx

The TMOUT argument is presented in seconds. Save and close.
I tried to put TMOUT=600 set for 600 seconds (10Min) in ETC/Profile and nothing happened at all. Now I saved as root, restarted the computer too and still it did not log out from the desktop after 10 min. Unless I didn't do something right?? Don't know...
gm10
Level 20
Level 20
Posts: 10558
Joined: Thu Jun 21, 2018 5:11 pm

Re: Automatic Logout

Post by gm10 »

No, you're not. As I already mentioned above, TMOUT is just for login sessions, it's irrelevant for what you are/were trying to do.
rjsrjs
Level 3
Level 3
Posts: 154
Joined: Sun Mar 17, 2019 6:47 pm
Location: Florida

Re: Automatic Logout

Post by rjsrjs »

gm10 wrote:
Sat Oct 05, 2019 1:46 pm
No, you're not. As I already mentioned above, TMOUT is just for login sessions, it's irrelevant for what you are/were trying to do.
Thank you gm10 I fully understand now. This thread is SOLVED
Post Reply