Expiry users in Linux


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expiry users in Linux
# 1  
Old 09-30-2012
Expiry users in Linux

Hi folks,

Need a bash shell script to find the expiry users in next 5 days in Linux using the command chage and dump the output to another file
# 2  
Old 10-01-2012
Try this... show some effort too...
Code:
#!/bin/bash

user_list="user1 user2"
today=$( date +%s )
for user in $user_list
do
  curr=$( chage -l $user | awk -F: '/Account Expires/{if(!index($0,"Never")){print $NF}}')
  test -z "$curr" && continue
  exp_date=$( date +%s -d "$curr" )
  ((val=($exp_date-$today)/(60*60*24)))
  [[ $val -eq 5 ]] && echo "$user expires by $curr" >> user_expiry_file
done

--ahamed
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Windows AD users authenticate to Linux

Hello folks, Please advise me what is the best way to authenticate Windows AD users against Linux machines. Currently I am going to take a look of Vintela Authentication Services and please let me know if you have experience with VIntela. Thanks in advance (1 Reply)
Discussion started by: Vit0_Corleone
1 Replies

2. UNIX for Dummies Questions & Answers

Check users in a Linux group

How do you check users in a linux group? (7 Replies)
Discussion started by: cokedude
7 Replies

3. UNIX for Advanced & Expert Users

Linux chat with other users

Besides talk and write are there any other good programs for talking to a particular user on the same Linux system. (1 Reply)
Discussion started by: cokedude
1 Replies

4. Homework & Coursework Questions

Problem with users in Linux

Hi. I have a problem with my homework. I have to do a Script that will tell me the number of users that are logged in on my system through a network and find out their IP's. Can you give me an idea? Thanks (1 Reply)
Discussion started by: mitzu
1 Replies

5. Shell Programming and Scripting

expiry of a linux id?

Hi, Can anyone suggest, how or from where we can understand the expiry time of a linux id, whether login or ftp? My concern is like, i want to know when the ftpid configured on an automated system will expire, so that i can configure some notice or email mentioning that the particular id... (1 Reply)
Discussion started by: DILEEP410
1 Replies

6. AIX

Migrating AIX users to Linux

Hi all, I was wondering if anyone out there knew if it was possible to migrate users from AIX to Linux. What we want to do is install OpenLDAP on a Linux machine and port all the users over to LDAP. I've googled around and could only find a few things, such as mrgpwd - but that only comes... (0 Replies)
Discussion started by: djcronos
0 Replies

7. What is on Your Mind?

New Site/Info for Linux Users

Check out this site. This will be helpful for all. Link removed. (3 Replies)
Discussion started by: jadebellant
3 Replies

8. Linux

Can Telnet in Linux 8.0 be restricted for users

Hi, I want to create a user and allow its to be able to have telnet session like what you have in the ftp allow and deny. Is this possible Thanx. (3 Replies)
Discussion started by: kayode
3 Replies
Login or Register to Ask a Question