TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: ADRIAN
date: 2018-12-07 23:10:00
subject: Re: Odd date behaviour

In message , druck 
writes
>On 07/12/2018 14:43, Adrian wrote:
>> Raspbrian 4.9.59-v7
>>  I'm seeing some odd behaviour with date in some stuff that a Pi is
>>running.
>>  I've got a cron job that runs every minute, calling a bash script. 
>>The script writes out to a log file every time it runs
>
>How are you writing to the file? Simple redirection of stdout?
>

Yes.

>> giving the state of a  sensor, typically four or five lines of
>>output, and each stage starts  with the time, generated by :
>>  date +%H%M
>>  If there is a change in the state of the sensor, then this will be
>>reported, using just the date command :
>>  echo `date` 
>
>Better to use:-
>
>    echo $(date) 
>

I've now changed to that, but it will likely be Monday before the next
state change. unless I force one.

>It's more reliable then back ticks which can have strange issues in
>scripts.
>> The strange thing is that the entries published every minute are
>>accurate, but in the change of state entries can be out by anything up
>>to 9 minutes late, the discrepancy varies.
>
>I'm not quite sure from your description if you mean the date in the
>log messages is wrong, or if the log entry is being put in the log file
>after entries which should precede it.
>

As the log is being done by simple redirection, entries should be in
chronological order.  Only one script is redirecting to the log.
Therefore I can't see how things can get out of order.  From the full
log info (which I snipped for brevity) it is obvious when the state
change is taking place.  So the time at the start of each section (e.g.
0630) is correct, but the full timestamp (including the date) is often
wrong, anything up to 9 minutes out (e.g. if the state change is at
0630, the full timestamp will be anything between 0630 and 0639), but
the next set of log entries will have the correct time (0631 in this
case).


Adrian
--
To Reply :
replace "bulleid" with "adrian" - all mail to bulleid is rejected
Sorry for the rigmarole, If I want spam, I'll go to the shops
Every time someone says "I don't believe in trolls", another one dies.

--- 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™.