The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 1,255β€…    Votes:  2β€…
Tags: power-management   shutdown   schedule  
Link: πŸ” See Original Answer on Ask Ubuntu ⧉ πŸ”—

URL: https://askubuntu.com/q/840031
Title: How to find out if computer was shut down at a given time?
ID: /2016/10/21/How-to-find-out-if-computer-was-shut-down-at-a-given-time_
Created: October 21, 2016    Edited:  June 12, 2020
Upload: March 26, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


Use syslog.1 to find hours system was running yesterday

If for example you wanted to know the hours your system was running yesterday you could use this command:

rick@dell:~$ grep cron.hourly /var/log/syslog.1

Oct 20 04:17:01 dell CRON[16062]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct 20 05:17:01 dell CRON[23665]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct 20 18:17:01 dell CRON[11680]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct 20 19:17:01 dell CRON[19789]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct 20 20:17:01 dell CRON[16936]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct 20 21:17:01 dell CRON[24757]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct 20 22:17:01 dell CRON[32481]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)

It shows us the system was active at 4 am and 5 am. Then it was active again at 6 pm, 7 pm, 8 pm, 9 pm and your magic number 10 pm represented by β€œ22:17:01”.

This methodology requires knowledge of system log files stored in /var/log and some commands such as cron which can be setup to run hourly. You could search for other commands such as wifi, print jobs, etc.

My system is a laptop that doesn’t actually shutdown but rather suspends and resumes when the lid is closed and opened so the solution needs to be different than the other answers offered so far.

⇧ What is the "Dirty COW" bug, and how can I secure my system against it? Disable suspend after screen lock  β‡©