(
First of all, I'm not completely sure what the official terms are.
I think it's "suspend"/"resume",
with "sleep"/"wake" being synonyms
(and I'm not sure if there are any other common synonyms).
And there's other, related-but-different stuff, namely "hibernate",
which is much more rarely used because hardware support for it is trickier and often not worth trying to mess with (I believe?).
(There's also "suspend-to-ram". I'm less clear whether that's a synonym for plain "suspend", or for "hibernate", or what.)
However, it's only "sleep"/"wake" that I'm interested in here.
)
---
So I wanted to look back through my system's journal to see what's been happening right after I wake the system from sleep.
(I have a USB keyboard that seems to not be coming back properly until I unplug-and-replug it, and I think it's a software issue, and I'm trying to figure it out.)
However, I'm not confident that I'm consistently finding the correct spots in the system journal.
Someone told me to manually run
(before sleep):
(after sleep):
Which seemed odd to me,
because I would've thought that something already logged to the journal by default would mark sleep/wake?
If so, what?
---
And if not, how should I add something to automatically log sleep/wake times?
And just in general,
how should I do scripting around sleep/wake?
eg, if I did want to take
and
and make them automatically run before and after sleep respectively
(as close as possible to the last/first thing before/after that sleep)?
I found this file:
should I be working with that?
(
Like, I guess I'm looking for the equivalent of an init-script,
but for wake/sleep rather than just boot/shutdown.
...
Although in the case of sleep, I note it's possible to just have a single script run,
with a command to sleep in the middle of the script,
and then, without needing to do anything else,
the rest of the script will continue running after you wake the computer back up.
Not sure whether that's the right way of doing things, but it's certainly in principle possible.
)
---
Also, I only just started using
Before that, I only used
-- just whenever I wanted to check if something had recently OOM'd or segfaulted or whatever.
However,
where it just counts seconds since boot,
and then naively turns that into a "human readable" timestamp,
but completely ignores sleep/wake
so the timestamps actually drift further and further back out of sync from the actual real time the longer have your computer running,
if you're sleeping it every night but not rebooting.
So do the timestamps for
or is that fixed?
First of all, I'm not completely sure what the official terms are.
I think it's "suspend"/"resume",
with "sleep"/"wake" being synonyms
(and I'm not sure if there are any other common synonyms).
And there's other, related-but-different stuff, namely "hibernate",
which is much more rarely used because hardware support for it is trickier and often not worth trying to mess with (I believe?).
(There's also "suspend-to-ram". I'm less clear whether that's a synonym for plain "suspend", or for "hibernate", or what.)
However, it's only "sleep"/"wake" that I'm interested in here.
)
---
So I wanted to look back through my system's journal to see what's been happening right after I wake the system from sleep.
(I have a USB keyboard that seems to not be coming back properly until I unplug-and-replug it, and I think it's a software issue, and I'm trying to figure it out.)
However, I'm not confident that I'm consistently finding the correct spots in the system journal.
Someone told me to manually run
(before sleep):
su root -c 'echo "Sleep started" > /dev/kmsg'
(after sleep):
su root -c 'echo "Sleep ended" > /dev/kmsg'
Which seemed odd to me,
because I would've thought that something already logged to the journal by default would mark sleep/wake?
If so, what?
---
And if not, how should I add something to automatically log sleep/wake times?
And just in general,
how should I do scripting around sleep/wake?
eg, if I did want to take
su root -c 'echo "Sleep started" > /dev/kmsg'
and
su root -c 'echo "Sleep ended" > /dev/kmsg'
and make them automatically run before and after sleep respectively
(as close as possible to the last/first thing before/after that sleep)?
I found this file:
/etc/systemd/sleep.conf
should I be working with that?
(
Like, I guess I'm looking for the equivalent of an init-script,
but for wake/sleep rather than just boot/shutdown.
...
Although in the case of sleep, I note it's possible to just have a single script run,
with a command to sleep in the middle of the script,
and then, without needing to do anything else,
the rest of the script will continue running after you wake the computer back up.
Not sure whether that's the right way of doing things, but it's certainly in principle possible.
)
---
Also, I only just started using
journalctl
like a week ago honestly.Before that, I only used
dmesg
occasionally (with the --ctime
/-T
flag)-- just whenever I wanted to check if something had recently OOM'd or segfaulted or whatever.
However,
dmesg --ctime
has a longstanding bugwhere it just counts seconds since boot,
and then naively turns that into a "human readable" timestamp,
but completely ignores sleep/wake
so the timestamps actually drift further and further back out of sync from the actual real time the longer have your computer running,
if you're sleeping it every night but not rebooting.
So do the timestamps for
journalctl
still have that bug,or is that fixed?