Tag Archives: time & dates

Calculate file age in Python.

I use a file’s age for many things, especially when it comes to monitoring servers with nagios. Every language has their own modules to do these things, so here is my quick example to calculate a file’s age with Python. import os from datetime import datetime stat = os.stat('/etc/php.ini') fileage = datetime.fromtimestamp(stat.st_mtime) now = datetime.now() [...]
Posted in Programming | Also tagged , | Leave a comment