Time limit on guest account - help needed [solved]

Forum rules
Before you post please read how to get help
Level 1
Level 1
Posts: 1
Joined: Sat Sep 17, 2011 7:29 pm

Time limit on guest account - help needed [solved]

Postby MintLover4Ever » Sat Sep 17, 2011 8:11 pm

I really need help with the creation of a script to allow access for timed intervals of 30 mins on a Guest account and since I am a complete beginner with scripting I hope the community can lend a generous hand with the development of said script.
Here's the story, I have recently refurbished a computer and installed Linux Mint 11 with very few noticeable issues. I created a Guest account for use by my clients to check email or edit some documents but the only problem that remains is the lack of a time limitation to prevent unnecessary extended use. I've Googled my brains out trying to find a viable option but to no avail, the only one that has what I want is http://u-scripts.blogspot.com/2010/03/automatic-logout-for-kids.html the only dependency is on Conky which is NOT compatible with the new linux mint 11. Here are the minimal parameters for what I'm looking for:

-a simple script that is engaged at login of Guest account
-script logs off only the Guest account after 30 minutes of use
-Does not affect the admin account which will also be engaged for extraneous purposes behind the scenes
-blocks re-login for 5 min (if possible)

For a more advanced version my only hope is for a timer that shows the amount of remaining time.
Last edited by MintLover4Ever on Sat Oct 29, 2011 3:20 pm, edited 1 time in total.

User avatar
Level 19
Level 19
Posts: 9698
Joined: Tue Aug 11, 2009 9:21 am
Location: United Kingdom

Re: Time limit on guest account - help needed

Postby Oscar799 » Sun Sep 18, 2011 3:14 am

Split from another thread and title edited

User avatar
Pilosopong Tasyo
Level 6
Level 6
Posts: 1423
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Time limit on guest account - help needed

Postby Pilosopong Tasyo » Mon Sep 19, 2011 5:02 am

How about a rough algorithm instead, just to give you a head start?

Code: Select all


# Some useful variables
TIME_NOW = current time expressed in seconds
END_TIME = computed ending time (also expressed in seconds)

# Countdown loop
  # Display a reminder once per minute
    display REMAINING_TIME on screen

  # Update the current time
  TIME_NOW = current time (expressed in seconds)
  sleep 1 # Don't hog the CPU!

# Time is up!
force logout user


Then you can set the script to run upon login of the guest account (via Startup Applications). The algorithm satisfies all your requirements (including remaining time notification) except the last one (blocks relogin for 5 minutes -- perhaps a future exercise?). Also note the algorithm doesn't take into consideration if the guest user logs out of the account before his/her alloted time is up. No need for conky either, though you might need to download a small package in order to display on-screen notifications.

Try to understand the logic of the above algorithm. It will help you tremendously if you get the idea how it works. Look up the following for hints as well:

    pkill / gnome-session-save
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].

Return to “Scripts & Bash”