setting time restrictions for me and my girlfriend
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
setting time restrictions for me and my girlfriend
Since using the computer has become an addiction for me and my partner we need time restrictions.
I feel like a dumb newbie because I have not succeeded in making it work, so I post it here. I have been using Linux quite a bit longer than a newbie. I am not very advanced in using it but still know my way around and can use cli if it's not too complicated.
I have added the to the bottom of /etc/gdm3
account required pam_time.so
to make gdm(3) login manager use time restrictions
that I can define in the next file
/etc/security/time.conf
I added the following to it.
*;*;*;A10000-0800
that should disable all services,
all tty's (and gdm to because of what I did to /etc/gdm3)
all users
all days of the week A1
from 0000 till 0800 hours
(one can exceed the time limit but one cannot
login after this time (see below).
When testing it that same evening
I could not login as a normal user anymore through gdm
so I thought that part at least did work.
(root login on the terminal still worked,
and that should also be disabled,
but not until after the issues are fixed)
But the next morning after 0800 I could not login through gdm,
while that should now be possible.
How do I fix this ?
I also made a cronjob to shut down the system
because when you exceed this time limit there is only
something mentioned in the syslog that you exceeded your limit
but it does not automatically logout the user.
Only when reentering the system I get the message permission denied.
crontab -e -u root
added this to the bottom of the crontab
55 23 * * * shutdown -h 5 now
But on both our systems the cronjob does not run
So it does not automatically shutdown.
There fore the time limiting also does not work.
We run Debian Linux.
I also tried to make a warning message appear
on X (windows) but I will open another thread for that
and post a link to that in this one for completeness
I apologize for any language mistakes because
English is not my native speech.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Rep:
I'm not sure why you wouldn't be allowed to log back in at 0800. (Caveat: I haven't used this feature on Linux but I know it works on other UNIX-variants.) Check the settings to be sure you have the time correctly defined. Specifically, check out the possible need for a "!" character in the time specification. You're right, though... that won't kick you out when the restricted window begins; only new logins would be prohibited.
Rebooting to kick everyone out seems a little draconian.
Perhaps you could set up a little utility that runs in the background when you log in that periodically checks to see how long you've been logged on and, if it's longer than your desired duration or outside of the window you want to allow, starts popping up an "xmessage" window every few minutes that says something like: "Hey! You've been logged in long enough! Get a life!" with options to click on "OK, I'll get off now." or "Go away, I'm having too much fun." options and log which one you clicked on. (Then you and your SO can compare log files so you can see how the other is handling their Internet addiction.)
Last edited by rnturn; 04-03-2013 at 03:29 PM.
Reason: Forgot comment about the "!" character in the PAM time filter.
I don't think that technical solution for this problem exist - even if you'll manage what you are trying to do,you always can easily boot from live cd or change time in the BIOS setup.
This worked but caused the system
to prompt a message shutdown is already running
when I tried to shutdown the system any time before midnight,
so this was not practical.
The cronjob is running now.
I originally tried to ad it with.
crontab -e -u root
That did not work.
But then I tried to add it directly in
/etc/crontab
That solved the problem for now.
I discovered I have to add
account required pam_time.so
to the file
/etc/pam.d/login
To disable root login also.
At least on debian linux this has to be added
to files in /etc/pam.d
to disable a particular service use the corresponding file.
However the unable to login again problem
in the morning still persists
The login problem
in the morning after 0800
is probably a bug somewhere.
I don't know if it is a Debian problem
or something in Linux in general.
I hope it is resolved soon.
If so I will post here again.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.