LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-23-2013, 01:27 AM   #1
zetrotrack000
Member
 
Registered: Dec 2011
Posts: 401

Rep: Reputation: Disabled
timed login


Hi
I am using ubuntu linux. I have created a new account for my nephew (for his college assignments). How can I make this account that I can only be loggedin during 6PM and 9PM, except these timings, this (new) account cannot be logged in?
Regards
 
Old 10-23-2013, 02:07 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
This link should solve all your needs http://askubuntu.com/questions/68918...computing-time
There are also some other links on LQ itself so give the search function a try.
 
Old 10-23-2013, 09:45 AM   #3
zetrotrack000
Member
 
Registered: Dec 2011
Posts: 401

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by zhjim View Post
This link should solve all your needs http://askubuntu.com/questions/68918...computing-time
There are also some other links on LQ itself so give the search function a try.
Thanks. timekpr solved the problem.
Another question arises, if the user is already logged in then after the expiry time, the session would logged out automatically or is there any other way to force user to logout after expiry of time?
 
Old 10-23-2013, 09:53 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Dunno. While skimming the link I read something about a warning when overextending the login period or before that happens. But if it was with timkpr or someother mentioned tool I don't know.
Check out the config file of timekpr and see if it got some options for kinda like that.
 
Old 10-23-2013, 09:56 AM   #5
zetrotrack000
Member
 
Registered: Dec 2011
Posts: 401

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by zhjim View Post
Dunno. While skimming the link I read something about a warning when overextending the login period or before that happens. But if it was with timkpr or someother mentioned tool I don't know.
Check out the config file of timekpr and see if it got some options for kinda like that.
While you were writing your answer, I have found a way and that is to create a cron job with following:
0 21 * * * /sbin/shutdown -h now

Last edited by zetrotrack000; 10-23-2013 at 09:59 AM.
 
Old 10-24-2013, 03:20 AM   #6
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
This for sure gets the server down but there might be occasion where the login period should be extended maybe cause all it takes are five minutes more to finish something. Right now this is not possible.

Maybe first see if someone is still logged in using who or w command. Then send a message to those users and check again in 5-10minutes then issue a second warning and after 2 minutes shutdown for sure.

Code:
if [ $(who | wc -l) -gt 0 ]; then
echo "sending message"
fi
sleep 300
if [ $(who | wc -l) -gt 0 ]; then
echo "sending message"
fi
shutdown +2
Something like this. Checking if a user is logged in might go in a function maybe.
Sending the message has to be evaluated again. On command line shutdown will take care of telling the user about going down. Dunno what about a GUI. Guess that depends on the window manager in use but most recent ones have some kind of notification ability.
 
Old 10-24-2013, 09:12 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Dunno ... might be better just to stand right behind him and bellow, "Time's up! Get off of my computer!"
 
Old 10-24-2013, 09:54 AM   #8
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 529

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Quote:
Originally Posted by zhjim View Post
... On command line shutdown will take care of telling the user about going down. Dunno what about a GUI. Guess that depends on the window manager in use but most recent ones have some kind of notification ability.
This is a problem I have considered. There are some GUI notification popups available, but I haven't found one that will stay visible on top when the user is busily using the keyboard or mouse, as might happen when he is playing a video game. The notification either gets buried when the user clicks on another window, or it dismisses itself when it receives keyboard or mouse clicks that were intended for the user's application.

One option in the gnome environment is to put a notification applet on the gnome panel. Then it would remain visible until the user clicks on gnome panel to dismiss it. It could even show the remaining time like a countdown timer, and change color when it reaches a critical level like 5 minutes remaining. I had hoped to develop such a gnome-panel applet, it doesn't look difficult, but I got distracted with other work. Does anyone know of a gnome-panel notification applet that's already available?
 
Old 10-26-2013, 12:57 PM   #9
zetrotrack000
Member
 
Registered: Dec 2011
Posts: 401

Original Poster
Rep: Reputation: Disabled
I used the following method:
I told my nephew that "the computer will shutdown automatically at 9PM, so save your work before that"
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] USB: Connection timed out SYS: Connection timed out PeterUK Programming 3 07-18-2013 02:59 AM
ssh login...do_ypcall: clnt_call: RPC: Timed out vincegreen Linux - Networking 1 07-07-2007 01:33 PM
ssh login...do_ypcall: clnt_call: RPC: Timed out vincegreen Linux - Networking 0 07-05-2007 07:37 PM
sendmail - Connection timed out [dsn=4.0.0 stat=Deferred: Connection timed out] ananthak Linux - Software 0 04-24-2007 07:28 AM
Error logging into SBP-2 device - login timed-out BlueSloth Linux - Hardware 1 07-30-2006 12:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration