Сравнение меток времени

Вы пробовали управлять PAM sufficient? Перpam.conf(5)

   sufficient
       if such a module succeeds and no prior required module has failed
       the PAM framework returns success to the application or to the
       superior PAM stack immediately without calling any further modules
       in the stack. A failure of a sufficient module is ignored and
       processing of the PAM module stack continues unaffected.

Это должно остановить обработку на вашей пользовательской строке:

auth sufficient pam_exec.so expose_authtok /usr/bin/custom-pam.sh

если он не терпит неудачу, что может быть обработано последующим nope -, отрицающим -вас -здесь.

0
22.01.2020, 11:51
1 ответ

Вы не указали свою ОС, но предполагая, что у вас есть GNU date, вы можете преобразовать дату в метку времени, а затем выполнить простое вычисление, чтобы определить, старше ли она двухчасовой давности:

datetime=$(
    aws s3 ls --endpoint=https://localhost s3://files/ |
    awk 'END {print $1, $2}'
)
timestamp=$(date --date "$datetime" +'%s')
timeAgo=$(date --date "2 hours ago" +'%s')

if [[ $timestamp -lt $timeAgo ]]
then
    echo "It's a really old file"
fi
2
28.01.2020, 02:38

Теги

Похожие вопросы