监控电脑使用时间

监控电脑使用时间

我想监控我使用电脑的时间。每个程序所花的时间会是一个很好的加分项,但不是必需的。正常运行时间不够,因为我可能会让电脑一直开着。我猜有些应用程序可以做到这一点,但我也可以接受更自下而上的解决方案(例如,监控用户输入或 X11 的活动以确定计算机是否正在使用,然后记录日志)。

答案1

不幸的是,这个答案并不能满足您的所有要求,但它们是您可以修改的 bash 脚本。

第一个解决方案是让您的计算机在不活动时自动挂起。然后这个脚本可用于:

$ suspendtime
Nov 10 13:51:52 to Nov 10 18:43:27 suspended 4 hours, 51 minutes, 35 seconds
Nov 11 00:33:26 to Nov 11 07:48:14 suspended 7 hours, 14 minutes, 48 seconds
Nov 11 13:23:28 to Nov 11 18:30:26 suspended 5 hours, 6 minutes, 58 seconds
Nov 11 21:48:00 to Nov 12 04:24:46 suspended 6 hours, 36 minutes, 46 seconds
Nov 12 05:51:51 to Nov 12 17:43:22 suspended 11 hours, 51 minutes, 31 seconds
Nov 12 21:51:33 to Nov 13 04:21:19 suspended 6 hours, 29 minutes, 46 seconds
Nov 13 05:54:53 to Nov 13 18:55:32 suspended 13 hours, 39 seconds
Nov 13 20:27:03 to Nov 13 23:11:23 suspended 2 hours, 44 minutes, 20 seconds
Nov 14 00:46:49 to Nov 14 07:27:29 suspended 6 hours, 40 minutes, 40 seconds
Nov 14 13:20:49 to Nov 14 18:56:52 suspended 5 hours, 36 minutes, 3 seconds
Nov 15 00:16:33 to Nov 15 07:33:53 suspended 7 hours, 17 minutes, 20 seconds
Nov 15 13:06:38 to Nov 15 18:07:34 suspended 5 hours, 56 seconds
Nov 15 21:46:09 to Nov 16 04:20:41 suspended 6 hours, 34 minutes, 32 seconds
Nov 16 05:55:28 to Nov 16 18:13:27 suspended 12 hours, 17 minutes, 59 seconds
Nov 16 21:36:22 to Nov 17 04:07:29 suspended 6 hours, 31 minutes, 7 seconds

Linux uptime 582,903 seconds ( 6 days, 17 hours, 55 minutes, 3 seconds)
15 Suspends 388,500 seconds ( 4 days, 11 hours, 55 minutes)
Real uptime 194,403 seconds ( 2 days, 6 hours, 3 seconds)

第二种解决方案接近您的需求,但没有日志记录。当您观看电影时,脚本使另外两个监视器变暗并记录 X11 中的不活动时间:

movie.sh状态显示.png

相关内容