Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Suppose I have a table with the current users logged in on my website. And if I there isn't any "activity" from one of his/her username in a time interval it would be deleted from the table.

What would be the easiest way to implement this functionality?

Besides using batch files or something like that.

I searched but database triggers can't be timed programmed, at least from what I gathered.

I'll be using a table with the usernames and timestamps to define their latest activity and consider that those who haven't done nothing in the last 10 mins are logged of.

share|improve this question
    
Which database are you using? –  Cypher May 27 '11 at 20:32
add comment

1 Answer 1

Scheduled or delayed actions are not something I expect from a database server. Actions like you want are generally programmed as an external service. Scheduling can be done using a variety of mechanisms. Crontab is one. For a Java application, Quartz is one option.

If you are querying the table to determine if someone is logged in, I would consider using a view including the relative time limit in the selection criteria. Date arithmetic is common database functionality. This would make cleaning up the table less time critical.

Oracle has a Jobs facility that is basically a crontab service provided by the database server. I don't know of any other databases with similar functionality.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.