Print elapsed time from installation script

While dusting off my Bash skills I wrote a small and simple script to print time elapsed since installation of current distribution.
It seemed to me as a pretty interesting statistic regarding my devotion to fix my system instead of reinstalling every now and then.
You can check the script code here:

My output:

41 days 17 hours 10 minutes and 35 seconds

Any comment is more than welcome.


Top job @arvchristos .

Thx for sharing.

1 Like

The canonical method for determining the time of installation in Arch Linux is to check the first line in /var/log/pacman.log because the age of the filesystem may differ if the system has been restored from a backup.

So perhaps use

INSTALL_DATE=$(awk 'NR==1{gsub(/\[|\]/,"");print $1,$2}' /var/log/pacman.log)
1 Like

I tried writing a more universal approach. However, I’m sure that the fact I ignored this filesystem inconsistency will bite me sooner or later. If you have a more generic than this Arch relevant approach I would be happy to hear it !!!

Yeah, the filesystem check is nice because it returns a result in my Debian system but the result is wrong because I’ve changed the filesystem about four times since the initial installation :slight_smile:

I’m not sure about a universal method that doesn’t rely on the filesystem time though, that’s a tricky one… :thinking:

1 Like

I could easily check for the distribution type and if it is Arch I have a solution. So Arch based are ok with your addition. Now I have to find a solution for all the others :smile:

I included this particular change in the latest gist version. It seems that it’s a long and uncertain journey till a universal bash script for this simple problem. However, Arch based ones are working and that’s a start! Thank you @Head_on_a_Stick

1 Like

Considering I ended up working on this script for longer than I expected, I move the code to a separate repository to track changes and curate a compatibility list of distributions that it is accurate. I leave the link here as well as at the top post! Thanks for the feedback guys!


Thx, keep it on mate !

1 Like