Linux - GeneralThis 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.
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.
I am away from my SuSE 9.1 system at the moment, but in YAST2 under account options (can't recall the exact name) there should be the option to allow/disallow the account at certain times of the day. Your other option, if that is not the case, is to set up a cron job - log her in and set it running - to force a logout after x amount of time.
Originally posted by Tinkster A
Alternatively, give every user a .xsession/.xinitrc
file that's owned by root and that they can't over-
write, change or delete and that starts your script
How do I do that ?
In case anyone is interested here is the program.
It will work for a PC if you set it running on start up
#want to know if the machine has been used today or not
#get today's date and a variable for today's date to store
ctimeto = time.ctime()
ctimetovar = ctimeto[0:11]
#define the file name to save work if we want to change it
filedatename = 'datelogin.txt'
x = 0
text_file = open(filedatename,"r")
print filedatename, "does exist"
cdatefromfile = text_file.readline()
print "In the file ",cdatefromfile
print "In the program", ctimetovar
print "line 17"
print "In line 17", cdatefromfile
if cdatefromfile != ctimetovar:
print "In line 18"
print "In line 23"
x = 1
print "In line 25"
print filedatename, "does not exist"
print "in yesterortoday x is", x
def writetofile(filename, ctimetovar):
#store today's date in a file
text_file = open(filename,"w")
#store the time used today in seconds
filename = 'timeinseconds.txt'
#if x is 0 then the PC has not been used today and so we don't care about the
#contents of this file and we want to overwrite give a value of 1 for the
#time the machine has been used
if x == 1:
print "Writing to file and removing deleting all data"
#this means the PC has not been used today
#print "x is not 0"
#they have used it do not overwrite this
#call a function that opens timeinseconds.txt and a) converts what is into
#an int and adds to until a certain number of seconds reached
#get the number of seconds last time used today
text_file = open(filename,"r")
#timeinsecs = 0
timeinsecs = text_file.readline()
timeinsecs = int(timeinsecs)
#print "The computer has been used for ", timeinsecs,"seconds today"
#time limit is the amount of time before the program and PC shut down
timelimit = 130 #time in seconds they should use the machine
while timeinsecs < timelimit:
timeinsecs = timeinsecs + 60
#timeinsecsstr = str(timeinsecs)
text_file = open(filename, "w")
print timelimit, "has finished "
#if you just want to debug and you don't want the PC to shut down comment out
#the line below
# Disable new Xcursor themes if none is specified resp. located in $HOME
# (use "unset XCURSOR_CORE" to enable them again later)
#if [ "x$XCURSOR_THEME" == "x" -a ! -d $HOME/.icons ]; then
# export XCURSOR_CORE=true
# unset XCURSOR_CORE
# Prevent keyboard bouncing for Toshiba Notebooks
# Means, disable AccessX
test -r /etc/sysconfig/sax && source /etc/sysconfig/sax
if [ "x$KBD_BOUNCE_FIX" = "xyes" ]; then
test -x /usr/X11R6/bin/xbounce && /usr/X11R6/bin/xbounce
# Uncomment next line to activate asking for ssh passphrase
# Add your own lines here...
# day planer deamon
# pland &
# finally start the window manager
# call failsafe
But either a) I did this wrong so it does not call the python program
or b) the .xinitrc file is not called when someone logs in.
It depends on how you start X / login whether the
system uses .xinitrc or .xsession. Using xdm or the
like will grab .xsession, startx will use .xinitrc. Try
renaming the file, and see again.
If the script is being started as that from the users
.xsession it will run with user-privileges. I'd suggest
you add a line for it for all users to /etc/sudoers and
start it via sudo from your script.
P.S.: Seems to me that trying to get a hold of
porttime for SuSE might have been faster ;)