[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Before $time
From: |
Alex fxmbsw7 Ratchev |
Subject: |
Re: Before $time |
Date: |
Wed, 12 Jan 2022 00:24:24 +0100 |
use date's %s seconds to compare
On Wed, Jan 12, 2022, 00:01 MN <promike1987@gmail.com> wrote:
> 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
>
>
- Before $time, MN, 2022/01/11
- Re: Before $time,
Alex fxmbsw7 Ratchev <=