zoukankan      html  css  js  c++  java
  • Linux 检测账号密码过期脚本

    vi user-password-expiration-check.sh
    
    #!/bin/sh
    for user in $(cat /etc/passwd |cut -d: -f1)
    do echo $user
    chage -l $user | grep "Password expires"
    done | paste -d " "  - - | sed 's/Password expires//g'
    
    chmod +x user-password-expiration-check.sh

    查看root的过期时间

    #/bin/bash
    
    # 从 19701100:00:00 UTC 到目前为止的秒数(时间戳)
    today=$(date +%s)
    expires_str=$(chage -l root|awk "NR==2"| cut -d ":" -f 2)
    
    if [ "$expires_str" == " never" ];then
        expire_days=99999
    else
        expiration=$(date -d "$expires_str" +%s)
        expire_days=$[(expiration-today)/86400]
    fi
    
    echo $expire_days
    
    #rm -f /tmp/root_pwd_expir_days_$(date -d "-1 days" +%F).txt
    
    #temp_file=/tmp/root_pwd_expir_days_$(date +%F).txt    
    #echo $expire_days |tee $temp_file
    #chown root:root $temp_file && chmod o=r $temp_file
  • 相关阅读:
    alpha冲刺3
    alpha冲刺2
    alpha冲刺1
    软工第七次作业
    软工第八次作业
    软工第六次作业
    软工第五次作业
    软工第四次作业
    Alpha冲刺一 (2/10)
    Alpha冲刺一(1/10)
  • 原文地址:https://www.cnblogs.com/joshua317/p/14523678.html
Copyright © 2011-2022 走看看