Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: is there a way to see who is logged on?

  1. #1
    Join Date
    Apr 2009
    Location
    NYC
    Beans
    328
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    is there a way to see who is logged on?

    I hosting a webpage uysing ubuntu 9 desktop with LAMP installed

    people log on and do stuff using php and mysql

    There are times when I need to reboot, and I would like to know if anyone is logged on, so i can reboot when no one is logged on.

  2. #2
    Join Date
    Nov 2005
    Location
    Bordeaux, France
    Beans
    11,292
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: is there a way to see who is logged on?

    Code:
    users
    「明後日の夕方には帰ってるからね。」


  3. #3
    Join Date
    Apr 2009
    Location
    NYC
    Beans
    328
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: is there a way to see who is logged on?

    i tried the code and it does not show be who it logged on my website.

    maybe "logged on" is not the right term,

    i want to know if there is a session running on my website.

    the "users" code i think is used for computer logged on to the server.

    I want to know if anyone singed on using a web browser,

  4. #4
    Join Date
    Nov 2005
    Location
    Bordeaux, France
    Beans
    11,292
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: is there a way to see who is logged on?

    Well then you have to implement that in your code, there is no direct way to do it.
    「明後日の夕方には帰ってるからね。」


  5. #5
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Php

    Quote Originally Posted by rhythmiccycle View Post
    I hosting a webpage uysing ubuntu 9 desktop with LAMP installed

    people log on and do stuff using php and mysql
    That would depend on your software written in PHP and how it tries to simulate account activity.

    The short real-world answer is: you can't. HTTP is inherently stateless.
    Every time a visitor gets something from your web site (a web page, an image for that web page, etc) the are logged in and then logged back out again.

    Whatever the PHP program does to try to hide that is basically a kludge. But it might have some method of calling the account logged off if there have been no new requests after some time period.

  6. #6
    Join Date
    May 2007
    Location
    Phoenix, Arizona USA
    Beans
    2,909
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: is there a way to see who is logged on?

    Quote Originally Posted by rhythmiccycle View Post
    I hosting a webpage uysing ubuntu 9 desktop with LAMP installed

    people log on and do stuff using php and mysql

    There are times when I need to reboot, and I would like to know if anyone is logged on, so i can reboot when no one is logged on.
    This should be pretty easy. Try this:

    Code:
    tiburon# netstat -f inet
    Active Internet connections
    Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
    tcp4       0      0  192.168.2.40.http      227.133.102.97.c.1099  TIME_WAIT
    tcp4       0      0  192.168.2.40.http      67-60-155-2.cpe..1032  FIN_WAIT_2
    tcp4       0      0  192.168.2.40.ssh       192.168.2.4.56771      ESTABLISHED
    udp4       0      0  localhost.ntp          *.*                    
    udp4       0      0  192.168.2.40.ntp       *.*
    You can see that I am logged on as 192.168.2.4, and the other IPs are of course users logged on to the web site. When you have no IPs logged on except yours, do your reboot.

    -Tim
    www.pcchopshop.net

    Hard to find and obsolete PC and server parts. "If we can't find it, it probably doesn't exist"

  7. #7
    Join Date
    Apr 2009
    Location
    NYC
    Beans
    328
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: is there a way to see who is logged on?

    Quote Originally Posted by windependence View Post
    This should be pretty easy. Try this:

    Code:
    tiburon# netstat -f inet
    Active Internet connections
    Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
    tcp4       0      0  192.168.2.40.http      227.133.102.97.c.1099  TIME_WAIT
    tcp4       0      0  192.168.2.40.http      67-60-155-2.cpe..1032  FIN_WAIT_2
    tcp4       0      0  192.168.2.40.ssh       192.168.2.4.56771      ESTABLISHED
    udp4       0      0  localhost.ntp          *.*                    
    udp4       0      0  192.168.2.40.ntp       *.*
    this is what I get when I try that:

    Code:
    mike@mike-desktop:~$ netstat -f inet
    netstat: invalid option -- 'f'
    usage: netstat [-veenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help}
           netstat [-vnNcaeol] [<Socket> ...]
           netstat { [-veenNac] -i | [-cnNe] -M | -s }
    
            -r, --route              display routing table
            -i, --interfaces         display interface table
            -g, --groups             display multicast group memberships
            -s, --statistics         display networking statistics (like SNMP)
            -M, --masquerade         display masqueraded connections
    
            -v, --verbose            be verbose
            -n, --numeric            don't resolve names
            --numeric-hosts          don't resolve host names
            --numeric-ports          don't resolve port names
            --numeric-users          don't resolve user names
            -N, --symbolic           resolve hardware names
            -e, --extend             display other/more information
            -p, --programs           display PID/Program name for sockets
            -c, --continuous         continuous listing
    
            -l, --listening          display listening server sockets
            -a, --all, --listening   display all sockets (default: connected)
            -o, --timers             display timers
            -F, --fib                display Forwarding Information Base (default)
            -C, --cache              display routing cache instead of FIB
    
      <Socket>={-t|--tcp} {-u|--udp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom
      <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: inet
      List of possible address families (which support routing):
        inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) 
        netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) 
        x25 (CCITT X.25)

    i tried alot of variations but I can't get a output like the one in your example.

    Do I need to install something?
    Last edited by rhythmiccycle; October 23rd, 2009 at 01:49 AM.

  8. #8
    Join Date
    May 2007
    Location
    Phoenix, Arizona USA
    Beans
    2,909
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: is there a way to see who is logged on?

    Sorry about that. I was on the FreeBSD box. This should work in Linux:

    Code:
    tigere:~ # netstat --inet
    The output should look like this:

    Code:
    tigere:~ # netstat --inet
    Active Internet connections (w/o servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State      
    tcp        0      0 tigere.dominicansto:ssh 192.168.2.4:59820       ESTABLISHED
    -Tim
    www.pcchopshop.net

    Hard to find and obsolete PC and server parts. "If we can't find it, it probably doesn't exist"

  9. #9
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    graceful shutdown of apache

    @ windependence : netstat doesn't show who is 'logged in' to the php app. It will show which connections are open, but that has little do to with the php app. And with http being stateless, the only option there is to use a timeout.

    An open tcp connection means that the ip address in question recently requested a web page.

    shutting down apache 'gracefully' should automatically accomplish anything you can do based on netstat data. A graceful shutdown means that the http transactions are allowed to complete and the connections close naturally.

    See:
    http://httpd.apache.org/docs/2.2/stopping.html

    It looks like that option is missing from /etc/init.d/apache2, so you will have to do it yourself:

    Code:
    sudo apache2ctl graceful-stop

  10. #10
    Join Date
    May 2007
    Location
    Phoenix, Arizona USA
    Beans
    2,909
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: graceful shutdown of apache

    Well, I know what you're saying but it should still give him an idea of whether there are people using his connection at the time. Just a suggestion.

    -Tim
    www.pcchopshop.net

    Hard to find and obsolete PC and server parts. "If we can't find it, it probably doesn't exist"

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •