How to remove user accounts that are old via cronjob


Recommended Posts

At work I've set up a Ubuntu server running 9.10, and open SSH installed. I've got it set up that I can run a script to add new users to the system, and when they log in using WINSCP or Filezilla on port 22, they get put into their own jailed shell, or chroot or whatever...they can only see files in their designated folder and nothing else.

My boss has asked a way to clean up old accounts from the system however, and I don't see a way to do this (I am not strong in shell scripting or unix/linux period). Since users don't actually log into the server, just ssh in, running "last" does not tell me when they were last on. Instead, I would have to refer to the auth.log files to see when users were SSH'd in. What I need to try to do is find some way to grep through the file, and find which users last logged in more than say, 30 days ago. If a users name was not seen in 30 days, or the last entry had a timestamp 30 days or older, then a script would pass that username to a deluser command to remove their account from the system.

Is there an easy way to do this? I don't mind doing it by hand, however it would be nicer to have some kind of automated system to delete these things (I already have a script that deletes files uploaded more than 2 weeks ago).

Thanks!

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.