Sep 8, 2009

How to get the date, when an account expires, when you just know the days from the expire field?

"usermod -e" can set an expire date according to the format defined in /etc/datemsk.

In /etc/shadow this is expressed in the expire field:
see the extract from the man page:

expire An absolute date expressed as the number of days
since the Unix Epoch (January 1, 1970). When
this number is reached the login can no longer
be used. For example, an expire value of 13514

To know when this is you can use python:
>>> import datetime
>>> d0=datetime.datetime(1970,1,1)
>>> delta=datetime.timedelta( days=14481 )
>>> d0+delta
datetime.datetime(2009, 8, 25, 0, 0)
or to calculate the days:

>>> (d-d0).days
Python is a wonderful thing for calculation with dates.