Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to find the number of users that are currently logged into a Django site running on Linux? I need to restart the server and I want to make sure there are 'few enough' people that it won't be too much a hassle.

share|improve this question
What CMS are you using? – Wesley Apr 5 '12 at 4:27
This is on Python/Django – David542 Apr 5 '12 at 4:31
First step: define what you mean by "logged in" for your particular use case. Once you've got that out of the way, implementation is trivial. – womble Apr 5 '12 at 5:54

To see what users are logged into Linux, you can use w or who.

The output of w on my machine:

wesley tty1 :0 Tue12 39:54m 1:34m 0.06s pam: gdm-password
wesley pts/1 :0.0 Tue16 1:38m 0.45s 0.44s ssh
wesley pts/3 :0.0 Tue16 1:38m 0.49s 0.47s ssh
wesley pts/5 :0.0 Tue20 0.00s 0.25s 0.03s w

The output of who on my machine:

wesley   tty1         2012-02-14 12:28 (:0)
wesley   pts/1        2012-02-14 16:24 (:0.0)
wesley   pts/3        2012-02-14 16:34 (:0.0)
wesley   pts/5        2012-02-14 20:46 (:0.0)

To see which users are logged into an application, such as WordPress or Joomla, will require different, application specific methods, however.

Since you're using Django, you will need to programmatically query the session model for non-expired sessions. Check out the Q/A titled "How to get the list of the authenticated users?" over on StackOverflow for a more thorough explanation.

share|improve this answer
This is a django, non-specific site. I'm basically looking to infer the number from either open sessions or some other method – David542 Apr 5 '12 at 4:32

How about apache mod_status.

share|improve this answer

Your Answer


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.