TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ELI THE BEARDED
from: MARTIN GREGORIE
date: 2018-12-08 02:07:00
subject: Re: Odd date behaviour

On Sat, 08 Dec 2018 00:56:31 +0000, Eli the Bearded wrote:

> I'm wondering what the check_state command is, and if it could ever take
> N > 1 (eg 10) minutes. And if it could, how is this log assembled to get
> a backwards jump in a timestamp.
>
No backward jumps needed. Cron "fires and forgets" every job it runs.

The OP's problem script usually gives the right result because his cron
job takes only a second or two to run, so log entries mostly appear in
the expected sequence, but if the state changes he appears to run a one-
line script that executes date in back-ticks and his Python code run
normally, so if the python hangs for a minute or more the timestamped
message will be written to the log AFTER the next one or more cron jobs
have run and logged their results, so its output hits the log after that.

Now, how come the timestamp matches the time when the job started rather
than when its output was written? That's because the OP is running

echo $(date) 

(actually he's back-ticking 'date', but the effect is the same: anything
inside backticks or $(...) runs before the rest of the line is executed.
If it didn't, then constructs which I use all the time, like:

less $(grep -l 'TARGET' *.java)

would not work. Since this does work, its execution sequence can only be:

(1) Run grep to build a list of Java sources containing TARGET.

(2) Insert the list into the line as command line parameters to less

(3) Start less showing the contents of the first file in the list.


--
Martin    | martin at
Gregorie  | gregorie dot org

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.