history 历史命令添加时间戳

  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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容