LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-30-2006, 05:42 AM   #1
grpprod
LQ Newbie
 
Registered: Nov 2005
Posts: 13

Rep: Reputation: 0
Expired user maintenance


Hello,
I was wondering if anyone has created a script (or can provide me with some guidelines/resources) to do the following:

1. Display the date in which a user account expires.
2. Send an email to all users that their account is about to expire.
3. Automatically remove expired accounts.

Thanks
 
Old 03-30-2006, 07:27 AM   #2
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
Sounds like homework
 
Old 03-31-2006, 01:47 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by grpprod
Hello,
I was wondering if anyone has created a script (or can provide me with some guidelines/resources) to do the following:

1. Display the date in which a user account expires.
chage -l <username>

Quote:
Originally Posted by grpprod
2. Send an email to all users that their account is about to expire.
using something like (untested):
Code:
for i in `awk -F: '{print $1}' /etc/passwd`; do

done
combined with the chage above and some date manipulation
should get you the alerts :)

Quote:
Originally Posted by grpprod
3. Automatically remove expired accounts.
That's a BAD idea. I'd suggest that you use a similar
method to the above and then notify the admin. Just think
about it - if people have shell accounts, and store data
(that may in some instance be of importance to the company)
you don't want to automatically delete it just because the
author is gone.


Cheers,
Tink
 
Old 04-02-2006, 03:46 AM   #4
grpprod
LQ Newbie
 
Registered: Nov 2005
Posts: 13

Original Poster
Rep: Reputation: 0
Thank you for your reply. Indeed this is a good starting point that has helped me a lot. One minor issue: is it possible to pass the derived variables to the e-mail that will go to the expired user? I mean, having something like this inside the main script:

Quote:
PASSWORD_AGE=.....
/usr/sbin/sendmail $1\@mydomain.com < expireMessage.txt
and inside expireMessage.txt:

Quote:
Subject:...
Your password is about to expire in $PASSWORD_AGE days.
 
Old 04-02-2006, 01:43 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Not if you define it as an external plain old text-file.

You have two possible alternatives:
1.) Make the expiryMessage a script in its own right, and invoke
it via
expiryMessage $1 $2 | sendmail ...
or
2.) you make the message part of the main-script as a HERE-document
sendmail <<MESSAGE
Your password is about to expire in $PASSWORD_AGE days.
MESSAGE


Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Login expired tulipysc Linux - Software 9 04-25-2007 07:29 PM
User expired Chemeh Mandriva 2 12-16-2005 09:59 AM
user account expired ??? rahimzai Red Hat 3 10-10-2005 05:03 AM
My user login session in SUSE Linux 9.1 version gets expired every now and then umesh.tiwari Linux - Software 1 12-06-2004 04:16 AM
password expired rbchhan Fedora 2 08-09-2004 10:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration