cancel
Showing results for 
Search instead for 
Did you mean: 
Create a Post
Highlighted
Sean_Roth
Ivory

R80 Clear Old Sessions Script

This is for made for MDS but it should work on a regular management server too.

 

Our MDS on R80.10 doesn't clear out old sessions when an admin uses SmartConsole. New sessions are created when admins log in and the old sessions just stick around, continually building up. That makes the sessions tab ugly to look at and makes it hard to find that session with locks that is giving you trouble that you want to discard.

 

This script removes all sessions that are logged out and have no changes (so a lock with no changes will get cleared too). I would have gone by locks instead of changes but when sessions are queried, locks is always at least 1. That might be a bug.

 

The usage is <scriptname> <days to save> <Y/N prompt for user & pw if needed>.  

 

For the option to prompt user & pw: in my experience, sometimes root login to a domain fails but the user login works. So if a Y is specified, then the script will try root login first, and if one fails, the script will prompt the user for a username & password to use instead (leaving the option blank or using anything that isn't a Y will result in root login attempts only).

 

In my environment, I used crontab to schedule the script as follows, and it works great: <script> 0 N

 

Use this script at your own risk. It works great for me but I cannot guarantee it is safe to use in your environment.