I’m Paul Herron, a full-stack developer and technical manager.
I focus mainly on back-end development with tools like Symfony
and devops with tools like Docker

Logging work hours with the help of an Awk script

by Paul Herron on 17 May 2014

As I’ve been freelancing recently I’ve been working across lots of different projects, and it’s been important to log exactly where the time has gone on each. This is something I’ve always tended to do anyway, even in full-time roles like SHOWstudio. There I was generally only working on one project – the SHOWstudio site – and because I was full-time I never had to issue an invoice for the work I’d done, but it’s still nice to have a record of what I did each day. I’ve often searched back through the log – sometimes years back – to find useful information about what I did and why, and of course it’s also reassuring to be able to account for your time if someone asks. Chances are if you asked me what I was working on yesterday and I hadn’t written it down, I’ll have forgotten most of what I got done.

I’ve had a simple workflow going for many years now which is that each project gets a log file that stores what I did on each day and how many minutes it took. At the end of the log I also have a massive to-do list running, which is constantly being amended. When I get something done I can just move it up into the log for that day, and add how long it took to the end of the line. The file looks like this:

---------- 2014-05-16 --------------------------|

Fix database crash when searching with special characters. [30]
Add new navigation to website header. [70]
Do offsite backups. [20]


---------- 2014-05-17 --------------------------|

Do mockup of new contact page. [120]


-- end --

Fix variable warning on homepage
Work out why dev server is unreachable from outside the network

This approach always did pretty much everything I needed so I was never really tempted to start using third-party time tracking services. One weakness it did have though was that it was tricky to add up all the time I’d spent on a given day, or as a grand total for the entire project. That’s why I ended up making a little Awk script that parses the file, tots up the minutes used on each task and outputs a simple report of it like this:

---------- 2014-05-16 --------------------------|

Fix database crash when searching with special characters. [30]
 +  30
Add new navigation to website header. [70]
 +  70
Do offsite backups. [20]
 +  20

Total for this day is 120  minutes (2 hours)


---------- 2014-05-17 --------------------------|

Do mockup of new contact page. [120]
 +  120

Total for this day is 120  minutes (2 hours)


-- end --

Grand total is 240  minutes (4 hours)

I’ve put the script on GitHub so if it’s of interest, go and grab it now!

Work Log script on GitHub

Back to homepage Back to blog listing

Next: