From: anonymous
Subject: [sr #111350] problems using date in .bash_profile
Date: Sat, 29 Nov 2025 22:09:49 -0500 (EST)
> Operating System: Rocky 9.6 (apparently)
> Hardware Platform: ??? (This is probably the most critical thing to know)
>I have added the following line to .bash_profile:
> export MOZ_LOG="compact:5,timestamp"
> export MOZ_LOG_FILE="/tmp/moz_log_file__$(date +%F_%H-%M-%S)"
>When I power up and log in, I can see that the file was created:
-rw-r--r--. 1 paul paul 0 Nov 29 17:52
/tmp/moz_log_file__2025-11-29_17-28-10.moz_log
>The date is always correct (so far) but the time is often off. A few
>times its right but usually it has no bearing to the time the file was
>created. I am not expecting exact but certain +/- one minute at most.
>The above example is dated about 26 minutes earlier than when file was
>created.
>Am I missing some understanding of state of my computer when
>.bash_profile is sourced? Or is this some form of a bug somewhere
>/ somehow? Is there a better way for me to do this (short of
>always opening a terminal, setting the envvar, and then firing off
>Thunderbird.
(Almost certainly) This has nothing to do with either bash or
coreutils (maintainers of the "date" utility). Rather, it has to do
with general computer management. My WAG as to what is going on is
this:
1) You're running on a hardware platform that doesn't have a real
time clock (RTC). For example, Raspberry Pi.
2) You're running on a GUI desktop, launched at boot time. This
means that the .bash_profile file gets run once, very early in
the process, shortly after booting. This means that the
time/date hasn't been properly synced from the Internet yet.
3) The reason it is close (within an hour or so at worst), but not
quite right is because of something called "fake-hwclock".
This is a sneaky little tool that sets the system time to
something close to right - based on the time when the machine
was most recently shutdown - until it can get properly synced
from the Internet.
Now, in terms of solutions - well, it isn't really clear that there is
any real problem or that a solution is needed. Maybe you are just
curious about why it does what it does - in which case, hopefully, the
above explanation is useful.
If I were doing this, I'd probably define a shell function like:
TB_with_Log() {
MOZ_LOG="compact:5,timestamp" MOZ_LOG_FILE="/tmp/moz_log_file__$(date
+%F_%H-%M-%S)" thunderbird "$@"
}
Then use that from the bash prompt to launch the bird (*). If I were
not the kind of person who is comfortable at the command line, then
I'd put something like the above in a script in ~/bin and then do
whatever is necessary to re-wire the GUI to run my script when
something/whatever is clicked.
(*) Note that you won't need to type in that whole long command name.
Just hitting TB then Tab should do it.
=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.
When responding to my posts, please try to refrain from giving bureaucratic
answers.
If you have nothing useful to say, then just click Next and go on.