Re: [arch-general] pacman.log has no timezone information in timestamp
On 02/03/2019 02:23, ProgAndy wrote:
Am 02.03.19 um 01:12 schrieb mpan:
I just used the /var/log/pacman.log for the first time to give me the last date-time I did a system upgrade ('starting full system upgrade' in the log). There is no time-zone info in the time-stamp. It's also not UTC. Does anyone know if this is by design or a bug? `pacman` uses local time of your system. Indeed it seems like an ommision.
You may consider opening a feature request, so pacman.conf would allow either an option to include TZ in the logs (good idea) or setting custom time format (worse idea, as this would bind `pacman` codebase to the specific time formatting function).
Meanwhile you can explicitly set the timezone to UTC when calling pacman, that way the log will be consistent:
$ TZ=UTC sudo pacman ...
-- ProgAndy
For some reason, ' $ TZ=UTC sudo pacman' and '$ sudo TZ=UTC pacman' both work, but '$ alias pacman="TZ=UTC pacman"' and then '$ sudo pacman' doesn't, even though (from what I know) it should be practically equal to '$ sudo TZ=UTC pacman'. Not sure why, but it was worth a shot. Any other way to automate this TZ=UTC for pacman so you don't have to type it every time. Maybe a wrapper script aliased to "upacman" or something? -- Regards, Juha Kankare
Am 02.03.19 um 02:43 schrieb Juha Kankare via arch-general:
On 02/03/2019 02:23, ProgAndy wrote:
Am 02.03.19 um 01:12 schrieb mpan:
I just used the /var/log/pacman.log for the first time to give me the last date-time I did a system upgrade ('starting full system upgrade' in the log). There is no time-zone info in the time-stamp. It's also not UTC. Does anyone know if this is by design or a bug? `pacman` uses local time of your system. Indeed it seems like an ommision.
You may consider opening a feature request, so pacman.conf would allow either an option to include TZ in the logs (good idea) or setting custom time format (worse idea, as this would bind `pacman` codebase to the specific time formatting function).
Meanwhile you can explicitly set the timezone to UTC when calling pacman, that way the log will be consistent:
$ TZ=UTC sudo pacman ...
-- ProgAndy
For some reason, ' $ TZ=UTC sudo pacman' and '$ sudo TZ=UTC pacman' both work, but '$ alias pacman="TZ=UTC pacman"' and then '$ sudo pacman' doesn't, even though (from what I know) it should be practically equal to '$ sudo TZ=UTC pacman'. Not sure why, but it was worth a shot. Any other way to automate this TZ=UTC for pacman so you don't have to type it every time. Maybe a wrapper script aliased to "upacman" or something?
Declaring an environment variable that way is a feature of some shells. It may not work in an alias, so you can use the env binary instead: alias pacman="env TZ=UTC pacman " A function should work as well pacman() { TZ=UTC /usr/bin/pacman "$@" }
On Sat, Mar 02, 2019 at 01:43:10 +0000, Juha Kankare via arch-general wrote:
For some reason, ' $ TZ=UTC sudo pacman' and '$ sudo TZ=UTC pacman' both work, but '$ alias pacman="TZ=UTC pacman"' and then '$ sudo pacman' doesn't, even though (from what I know) it should be practically equal to '$ sudo TZ=UTC pacman'. Not sure why, but it was worth a shot.
If you run a command with sudo, it won't expand aliases. You'd need to define an alias for sudo itself (see alias(1p), EXAMPLES section, example 4). Then again, I'm not sure if defining an alias for sudo is considered good practice. Also, for this matter, a wrapper script would be cleaner, as it doesn't depend on which user is running it, in which environment, in which shell, etc.
Any other way to automate this TZ=UTC for pacman so you don't have to type it every time. Maybe a wrapper script aliased to "upacman" or something?
Something like /usr/local/bin/pacman that calls /usr/bin/pacman, for instance (or more robustly, ../../bin/pacman relative to itself, to also account for cases where root is a subdirectory/mountpoint) comes to mind as a not-too-ugly workaround. Best, Tinu
participants (3)
-
Juha Kankare
-
ProgAndy
-
Tinu Weber