Project

General

Profile

Demande #4606

Ajouter un horodatage dans l'historique bash

Added by pitchum . over 3 years ago. Updated about 3 years ago.

Status:
Fermé
Priority:
Normale
Category:
-
Start date:
07/25/2020
Due date:
% Done:

0%

Estimated time:

Description

Je propose de faire en sorte que les historiques Bash de nos machines soient datés.
De sorte qu'en tapant la commande history on obtienne quelque chose comme ça :

  522  [2020-07-25 20:09] systemctl status drbd
  523  [2020-07-25 20:13] drbd-overview 
  524  [2020-07-25 20:28] history | grep drbdadm

Pour ce faire, il suffit d'ajouter cette ligne quelque part dans un fichier de config de bash, par exemple dans un fichier /etc/profile.d/bash_timestamps :

export HISTTIMEFORMAT="[%F %H:%M] "

Le plus propre serait que ce fichier soit présent dans le paquet Debian sexy-chapril pour que ce comportement soit le même sur toutes les machines de l'infra.

History

#1

Updated by pitchum . over 3 years ago

  • Description updated (diff)
#2

Updated by Christian P. Momon about 3 years ago

  • Target version changed from Sprint 2020 été to Backlog
#3

Updated by Christian P. Momon about 3 years ago

  • Status changed from Nouveau to Confirmé

Lors de la réunion mensuelle animsys du 04/11/2020, décision d'adopter la proposition. À faire \o/

#4

Updated by Christian P. Momon about 3 years ago

Reste la question du formatage à débattre.
Sur le SI April, on trouve :

(April) root@bots:/etc/profile.d[master$]# grep HISTTIME *
ee-bash.sh:    export HISTTIMEFORMAT="%F %T: " 
history.sh:export HISTTIMEFORMAT="%c " 

(April) root@bots:/etc/profile.d[master$]# history |head
    1  sam. 07 nov. 2020 04:28:33 CET emacs conf/hebdobot.conf
    2  sam. 19 mai 2018 04:15:11 CEST ll
    3  sam. 19 mai 2018 04:15:13 CEST ll conf/
    4  sam. 19 mai 2018 04:15:21 CEST ll

cpm@ocmstar (04:44:47) /etc/profile.d 19 > export HISTTIMEFORMAT="%F %T: " 
(April) root@bots:/etc/profile.d[master$]# history |head
    1  2020-11-07 04:28:33: emacs conf/hebdobot.conf
    2  2018-05-19 04:15:11: ll
    3  2018-05-19 04:15:13: ll conf/
    4  2018-05-19 04:15:21: ll

Pitchum propose :

export HISTTIMEFORMAT="[%F %H:%M] " 

cpm@ocmstar (04:43:52) /etc/profile.d 18 > history | tail
 5008  [2020-11-07 04:34] man strftime
 5009  [2020-11-07 04:38] history
 5010  [2020-11-07 04:41] man strftime
 5011  [2020-11-07 04:43] export HISTTIMEFORMAT="[%F %H:%M] " 

Faudrait se décider :D

Pour rappel, extrait du man strftime :

       %c     The preferred date and time representation for the current locale.
       %F     Equivalent to %Y-%m-%d (the ISO 8601 date format). (C99)
       %H     The hour as a decimal number using a 24-hour clock (range 00 to 23).  (Calculated from tm_hour.)
       %M     The minute as a decimal number (range 00 to 59).  (Calculated from tm_min.)
       %T     The time in 24-hour notation (%H:%M:%S).  (SU)

#5

Updated by Didier Clermonté about 3 years ago

OK pour 5008 [2020-11-07 04:34] man strftime

#6

Updated by Christian P. Momon about 3 years ago

  • Status changed from Confirmé to En cours de traitement
  • Assignee changed from pitchum . to Quentin Gibeaux

Discussion pendant le camp et décision d'adopter le format proposé par Pitchum \o/

#7

Updated by Quentin Gibeaux about 3 years ago

  • Status changed from En cours de traitement to Résolu

sexy-chaprilisé, installé partout

#8

Updated by Quentin Gibeaux about 3 years ago

  • Status changed from Résolu to Fermé
#9

Updated by Christian P. Momon about 3 years ago

  • Target version changed from Backlog to Sprint 2020 novembre

Also available in: Atom PDF