我想检查我的linux系统何时触发了哪个命令 - 在哪个日期和时间.
我解雇了这样的命令:
history 50 
它显示了最后50个命令的历史记录,但没有显示它被触发的日期和时间.有谁知道怎么做?
Hos*_*ani 21
关于此链接,您可以通过执行以下命令使krzyk永久提供第一个解决方案:
echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
source ~/.bash_profile
evo*_*ved 10
如果您使用的是 zsh,您可以使用例如-Eor-i开关:
history -E
如果您执行man zshoptions或man zshbuiltins您可以找到有关这些开关的更多信息以及与历史记录相关的其他信息:
Also when listing,
 -d     prints timestamps for each event
 -f     prints full time-date stamps in the US `MM/DD/YY hh:mm' format
 -E     prints full time-date stamps in the European `dd.mm.yyyy hh:mm' format
 -i     prints full time-date stamps in ISO8601 `yyyy-mm-dd hh:mm' format
 -t fmt prints time and date stamps in the given format; fmt is formatted with the strftime function with the zsh extensions  described  for  the  %D{string} prompt format in the section EXPANSION OF PROMPT SEQUENCES in zshmisc(1).  The resulting formatted string must be no more than 256 characters or will not be printed
 -D     prints elapsed times; may be combined with one of the options above
试试这个:
> HISTTIMEFORMAT="%d/%m/%y %T "
> history
当然,您可以根据自己的喜好调整格式.
它取决于标准 bash 中的 shell(及其配置),仅存储命令而不存储日期和时间(检查.bash_history那里是否有时间戳)。
要让 bash 存储您需要在执行命令HISTTIMEFORMAT 之前设置的时间戳,例如 in.bashrc或.bash_profile。这将导致 bash 将时间戳存储在.bash_history(请参阅以 开头的条目#)。
小智 5
HISTTIMEFORMAT="%d/%m/%y %H:%M "
对于在此之前键入的任何命令,这都没有帮助,因为它们只会获得打开历史记录的默认时间,但它将记录此后任何其他命令的时间。
如果您希望它永久记录历史记录,您应该将以下行放入您的~/.bashrc
export HISTTIMEFORMAT="%d/%m/%y %H:%M "
| 归档时间: | 
 | 
| 查看次数: | 73072 次 | 
| 最近记录: |