【问题标题】:Script to alert when Root Password Expiry in AIXAIX 中 Root 密码到期时发出警报的脚本
【发布时间】:2013-12-02 23:32:25
【问题描述】:

我正在尝试在 AIX 中构建一个脚本,我计划将其作为 cron 作业运行。 我希望脚本检查 root 密码是否会在 10 天内过期并触发电子邮件。我已经编写了一个脚本来触发邮件,但我不确定如何编写一个用于 root 密码到期的脚本。

这是发送邮件的脚本。

#!/bin/sh
sendmail -t -F 'ABC ' -f 'abc@xyz.com' << test.mail
From: ABC <abc@xyz.com>
To:  def@xyz.com
Subject:
Password expired in 10 days

这个脚本运行良好。

但我想要一个用于 AIX 的脚本,该脚本将在到期日期后 10 天内检查 root 密码是否到期。

【问题讨论】:

标签: shell aix


【解决方案1】:

你可以这样做,

lastupdate=lssec -f /etc/security/passwd -a lastupdate -s &lt;username&gt; | cut -d " " -f2 |cut -d "=" -f2

maxage=lsuser -a maxage itimadm | cut -d " " -f2 |cut -d "=" -f2 maxage=$(($maxage*7))

过期=$(($lastupdate+(60*60*24*$maxage))) expire_date=perl -le 'print scalar localtime $expires

剩余天数=ceil((($expires - $now) / (60*60*24)) - 1)

回显 $username,$maxage,$expire_date,$daysremaining

虽然这不是完整的脚本,但存在逻辑(可以改进:)),您可以添加 if 子句来检查条件(daysremaining

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-06
    • 2016-03-19
    • 1970-01-01
    • 2012-06-29
    • 2015-03-15
    • 2022-12-05
    • 2014-11-25
    • 1970-01-01
    相关资源
    最近更新 更多