Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! jr0sco's Avatar
    Join Date
    Aug 2010

    Account Users Time Usage

    Hi Guys,


    I want to get all users time usage on a linux system via the last or ac commands and using a perl script to manipulate the output of the data. What I need is to use logrotate and then run something like
    "/usr/bin/ac | perl /root/utils/" and empty the /var/log/wtmp after backing up to .e.g /var/log/wtmp-YYYY-MM-DD.gz

    I'm using logrotate on /var/log/wtmp like this "logrotate /root/conf/logrotate.conf"

    This is what my /root/conf/logrotate.conf file looks like

    #Start of file
    /var/log/wtmp {
        create 0664 root utmp
    			/usr/bin/ac | perl /root/utils/ #This script is the one to I use to manipulate the time usage data
    	rotate 5
    #End of file
    So this all works fine, but after running logrotate against the wtmp data file any current users logged onto the system will not have their time usage recorded to the wtmp file until they logout and login. Basically I need this process to work in realtime so any current user logged on the system at time the logrotate command is issued will have their time record on the fly in realtime without having to logout and login again. Currently the logged in users will not record their time usage to the new wtmp file.

    There could a better way to account for user time, but I'm unaware of any other way. I have look through Google and haven't really found anything useful.

    If anyone needs more info I will be happy to provide it.

    System Information:

    Distributor ID: Debian
    Description: Debian GNU/Linux 6.0.4 (squeeze)
    Release: 6.0.4
    Codename: squeeze

    logrotate version 3.7.8-6

    Kernel : 2.6.32-5-xen-686


    Joel C
    Last edited by jr0sco; 03-14-2012 at 05:26 AM. Reason: spelling mistakes

  2. #2
    Have you tried this?

    How to keep a detailed audit trail of what’s being done on your Linux systems

    The logrotate command is meant to be used as a daily function unless you want to write a script that continuously deletes the files and then use the -f command to force log to recreate the files.
    Last edited by dethklok02895; 03-15-2012 at 08:46 PM. Reason: Dug up new Info

  3. #3
    Just Joined! jr0sco's Avatar
    Join Date
    Aug 2010
    I have had a look at the website you provided. Getting the usage for a user is working ok, its when I run the logrotate -f /etc/logrotate.conf (I am using the -f option I forgot to mention that) when I do a logrotate -f /etc/logrotate.conf this will empty the wtmp file and any user currently logged in will not have their usage record til they logout and login again, so I need to refresh the wtmp file to start writing info about users currently logged on the system after running logrotate.

  4. $spacer_open
  5. #4
    The website I provided does not use logrotate. It uses account monitoring packages.

    And yes -f clears the logs and forces them to be rewritten. Like I mentioned logrotate is more of a day to day check than a real time.

    The website I listed does have a method for showing in "real time" how long the user was on.

    Outside of that the best I can think is look into a freeware network monitoring tool.

Posting Permissions

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