LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-28-2016, 03:17 AM   #1
mht08
LQ Newbie
 
Registered: Jun 2016
Posts: 2

Rep: Reputation: Disabled
Logging usage hours


Hi all,

This is a process-accounting question. I need to be able to track the total hours of user logged in time for each day on a workstation.

I have tried psacct (ac -d --file /var/log/wtmp). It should give me login time in hours, but strangely, it gives me numbers greater than 24 hours. Any idea why this is?

I'm open to recommendation of other programs/tools that can achieve my goal.

Thanks,
Carmen
 
Old 06-28-2016, 03:33 AM   #2
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Seems you need
Code:
last <username>
 
Old 06-28-2016, 03:48 AM   #3
mht08
LQ Newbie
 
Registered: Jun 2016
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hi Teufel,

I've tried the last command, but it gives me results that is very difficult to parse.
It gives me results in intervals of a few minutes. Here is a snapshot of what I get when I use last:

mht pts/6 :0 Wed Jun 1 14:39 - 14:50 (00:10)
mht pts/10 :0 Wed Jun 1 13:10 - 13:13 (00:02)
mht pts/4 :0 Wed Jun 1 13:09 - 09:40 (20:30)
mht pts/4 :0 Wed Jun 1 12:59 - 13:09 (00:10)
mht pts/9 :0 Wed Jun 1 12:55 - 14:30 (01:34)
mht pts/7 :0 Wed Jun 1 12:47 - 09:40 (20:52)
mht pts/7 :0 Wed Jun 1 12:30 - 12:47 (00:16)
mht pts/4 :0 Wed Jun 1 12:27 - 12:56 (00:29)
mht pts/4 :0 Wed Jun 1 12:08 - 12:27 (00:19)
mht pts/7 :0 Wed Jun 1 10:26 - 12:04 (01:37)

Is there something wrong with how my system is configured, seeing that psacct and last results are not what I expect them to be?
 
Old 06-29-2016, 02:19 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
pts = pseudo-terminal ie xterm session (or equiv); that's why you have so many.
 
Old 06-29-2016, 03:34 AM   #5
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
last <username> /var/log/wtmp

last <username> /var/run/utmp

users <username> /var/log/wtmp

Last edited by JJJCR; 06-29-2016 at 03:48 AM. Reason: edit
 
Old 06-29-2016, 10:32 AM   #6
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Seems there is no command that gives ready to use output and you have to parse the output of last command. I'd use "last reboot" and "last shutdown" commands as helpers.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] get disk usage of files modified in last 24 hours izzabdullah Linux - Server 1 04-19-2012 04:18 PM
[SOLVED] How do I calculate the hours usage per day over a certain period? linustalman Linux - General 2 12-14-2010 03:18 AM
Flash audio frozen in a loop in Firefox on Debian after some hours of usage. tospo Linux - Software 5 11-12-2010 05:30 AM
LQ slows down every few hours. Logging out solves the problem. damgar LQ Suggestions & Feedback 24 05-27-2010 08:44 AM
Server aburptly stops running High CPU usage PERL script after about 5 hours bpmee Linux - Server 3 05-18-2007 11:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration