Author: jpuyy

  • 常用数字

    86400 sec= 1d

    2592000 sec = 30d

    1440 min=1d

  • linux 用户密码过期

    明明使用 公私钥 登陆,确提示密码不对。

    使用 chage 来防止密码过期。

    查看当前的过期时间

    chage -l vagrant
    Last password change					: never
    Password expires					: never
    Password inactive					: never
    Account expires						: never
    Minimum number of days between password change		: 0
    Maximum number of days between password change		: 99999
    Number of days of warning before password expires	: 7
    

    设置密码永不过期

    chage -m 0 -M 99999 -I -1 -E -1 vagrant
  • redis set使用

    统计集合 key 的 member 的数量

    SCARD hello:step:3000:obj_type0
  • gitlab fork库与源库保持更新

    fork 之后做自己的功能,要与源库进行功能合并时用 MergeRequest

    但是如果自己的库与源库落后太多,则可以这样

    查看远程 repo

    git remote -v

    如果里面只能看到你自己的两个源(fetch 和 push),那就需要添加主repo的源:

    git remote add upstream URL
    git remote -v
    

    如果想与主repo合并:

    git fetch upstream
    git merge upstream/master
    或 git rebase upstream/master
    
  • timedatectl

    centos7 中查看时区

    [vagrant@localhost ~]$ timedatectl status
          Local time: Wed 2016-08-24 11:04:27 EDT
      Universal time: Wed 2016-08-24 15:04:27 UTC
            RTC time: Wed 2016-08-24 15:04:27
           Time zone: America/New_York (EDT, -0400)
         NTP enabled: n/a
    NTP synchronized: no
     RTC in local TZ: no
          DST active: yes
     Last DST change: DST began at
                      Sun 2016-03-13 01:59:59 EST
                      Sun 2016-03-13 03:00:00 EDT
     Next DST change: DST ends (the clock jumps one hour backwards) at
                      Sun 2016-11-06 01:59:59 EDT
                      Sun 2016-11-06 01:00:00 EST
    

    更改时区(sudo)

    timedatectl set-timezone Asia/Shanghai
    

    设置时间

    timedatectl set-time '2013-06-02 23:26:00'
    

    设置 ntp 时间同步

    timedatectl set-ntp yes

    官方文档
    https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/chap-Configuring_the_Date_and_Time.html

  • logrotate

    添加配置文件

    cat /etc/logrotate.d/myservice
    
    /data/log/myservice/*.log
    {
        rotate 7
        daily
        dateext
        dateformat .%Y%m%d
        compress
        missingok
        notifempty
        sharedscripts
        postrotate
          /usr/bin/killall -HUP rsyslogd >/dev/null 2>&1 || true
        endscript
    }

    debug 配置文件是否正确,但不会真正动你的 log

    logrotate -d /etc/logrotate.d/myservice

    真实测试 logrotate 情况

    logrotate -f /etc/logrotate.d/myservice