rmysql - cron facility

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • AR John

    #1

    rmysql - cron facility

    Hi,

    Anybody could tell me how a mysql script could be run on mysql on some
    interval like cron facility in Linux system?. I am using Windows 2K
    machine.

    Actually I am developing a PHP application by which if any user logged
    in but idle for 10 minutes then the user will be forced logged out. To
    implement it I am saving timestamp of the user's login time on mysql
    database. The daemon/service script will identify this type logged
    user's and delete its timestamp records from database. How this could
    be done?

    Thanks
    Manik
  • BDR

    #2
    Re: rmysql - cron facility

    That's not really a great idea... You're better off running the whole
    security bit from your own program. Just run this query (with your own
    tablename, timestampcolumn name), whenever the script is accessed by
    anyone, and put it prior to validation of the rest of the user's
    credentials:

    update tablename set `timestampcolum n` = '00-00-00' where
    date_sub(now(), interval 10 minutes) > `timestampcolum n`

    The above query will eliminate ALL login values (ie, ALL users) in your
    table that haven't been accessed within 10 minutes - assuming you're
    letting timestamp update the column during normal accesses.

    You can make login time success easier to manage by having a logged in
    field, and update and check that....

    update tablename set `timestampcolum n` = '00-00-00', `loggedin`='N'
    where date_sub(now(), interval 10 minutes) > `timestampcolum n`

    Now validate user credentials easily with:

    select loggedin from tablename where `sessionid`='$s essionid'
    if ($loggedin eq 'N') blah blah..

    Then do your logical if then else whatever (I do perl, but not php sorry )
    just my 2 cents anyway.
    Good luck.


    AR John wrote:[color=blue]
    > Hi,
    >
    > Anybody could tell me how a mysql script could be run on mysql on some
    > interval like cron facility in Linux system?. I am using Windows 2K
    > machine.
    >
    > Actually I am developing a PHP application by which if any user logged
    > in but idle for 10 minutes then the user will be forced logged out. To
    > implement it I am saving timestamp of the user's login time on mysql
    > database. The daemon/service script will identify this type logged
    > user's and delete its timestamp records from database. How this could
    > be done?
    >
    > Thanks
    > Manik[/color]

    Comment

    Working...