自动化linux系统Linux

history 历史命令添加时间戳

2021-07-02  本文已影响0人  Joening
  1. 打开Linux系统环境变量配置文件 ,
    vim /etc/profile
    添加: export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S"
    保存退出:
    source /etc/profile 或者 . /etc/profile
    再次输入history
    [root@web-server ~]# history |head -5
    1 2020-05-17 15:23:27 clear
    2 2020-05-17 15:23:29 history -w
    3 2020-05-17 15:23:30 ll
    4 2020-05-17 15:23:31 cd /root/
    5 2020-05-17 15:23:31 ls

shell脚本中禁止使用ctrl +c Ctrl +d 键
直接在脚本中添加trap '' INT 即可实现

修改系统时间和网络时间同步
1.yum -y install ntp ntpdate
2.ntpdate cn.pool.ntp.org
3.hwclock --systohc

上一篇下一篇

猜你喜欢

热点阅读