By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,333 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,333 IT Pros & Developers. It's quick & easy.

rmysql - cron facility

P: n/a
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
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
BDR
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 `timestampcolumn` = '00-00-00' where
date_sub(now(), interval 10 minute) > `timestampcolumn`

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 `timestampcolumn` = '00-00-00', `loggedin`='N'
where date_sub(now(), interval 10 minute) > `timestampcolumn`

Now validate user credentials easily with:

select loggedin from tablename where `sessionid`='$sessionid'
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:
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
AR John wrote:
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


Jul 19 '05 #2

P: n/a
BDR
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 `timestampcolumn` = '00-00-00' where
date_sub(now(), interval 10 minutes) > `timestampcolumn`

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 `timestampcolumn` = '00-00-00', `loggedin`='N'
where date_sub(now(), interval 10 minutes) > `timestampcolumn`

Now validate user credentials easily with:

select loggedin from tablename where `sessionid`='$sessionid'
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:
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


Jul 19 '05 #3

P: n/a
BDR
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 `timestampcolumn` = '00-00-00' where
date_sub(now(), interval 10 minute) > `timestampcolumn`

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 `timestampcolumn` = '00-00-00', `loggedin`='N'
where date_sub(now(), interval 10 minute) > `timestampcolumn`

Now validate user credentials easily with:

select loggedin from tablename where `sessionid`='$sessionid'
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:
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
AR John wrote:
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


Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.