Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the Bash script in linux to send an email containing a list of user accounts that expire within a few days

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use the Bash script in linux to send an email containing a list of user accounts that expire within a few days. I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it.

1) check the list of user accounts that expire after 10 days

This script will help you check the list of user accounts that expire within 10 days on the terminal.

# vi / optamp scriptAccordUserPayPasswordwords. Echo echo "- -" echo "UserName The number of days the password expires" echo "-- -- "for usern in u1u2u3u4dotodaytime $(date +% s) userexpdate=$ (chage-l $usern | grep 'Password expires' | cut-d:-f2) passexp=$ (date-d" $userexpdate "" +% s ") exp= `expr\ ($passexp-$today\) `expday= `expr\ ($exp / 86400\) `echo" $usern $expday "> > / tmp/user-expiry.txtdonecat / tmp/user-expiry.txt | awk' $2

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report