How to run an automation check to determined the stagnant user in Directory

How to run an automation check to determined the stagnant user in Directory

Hi,

Is there a way for user to write a custom function to disable user  that have been stagnant for certain days ?
for eg: total account have 100 license for user
there is a need of automation to determined the stagnant user for 60 days, then automatically disable the active user. (maybe can check through user login log)
if custom function cannot make it, please suggest a workaround.

Thank you