[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Before $time
From: |
MN |
Subject: |
Before $time |
Date: |
Wed, 12 Jan 2022 00:00:26 +0100 |
Hello,
I don't always know how much time my script is going to take, so I
started writing a function that do "this" before a certain time and
"that" if the time has already passed.
Currently the "this" and "that" are hibernate and suspend.
For example; if the time is set to 16:00 and the current time is only
15:59 or less then it should hibernate the system.
There are two questions.
1) How should I compare the two time values? I think my approch is bad.
2) How good is the rest of the script?
local d
d=$(date '+%H:%M')
if [[ "$d" -lt "$1" ]]
then systemctl hibernate
else systemctl suspend
fi