December 14, 2012

bash based time tracking

Time tracking has been a recurring theme in my career as software developer. I’ve previously developed multiple solutions to do this myself, but this is the one that I like the most - and since I’ve been using it for about half a year now it’s time to publish it:

say hello to traq - bash based time tracking which works on Linux and OS X

I like to be in control of my own data. Traq gives me complete control and it complies with unix best practice by using a text based format which can be easily read & manipulated by a human.

Usage

traq enables you to track times for different clients into different folders so you can easily evaluate them later.

To start time tracking for website-a I’m working on all I need to execute is

traq -p client website-a

Later the same day before going to lunch I execute

traq -p client stop

to stop the tracking.

Anytime I want to know for how long I’ve been working I can execute this:

traq -p client -w 50
per week or
traq -p client -d 2012-12-09
per date or
traq -p client
for today only.

The output lists all tracked hours like this:


Sun Dec 09 16:07:38 +0100 2012;#project
Sun Dec 09 16:51:26 +0100 2012;#meeting
Sun Dec 09 19:43:39 +0100 2012;stop
%%

Now I’d like to know for how long I’ve been working on a given project. For this I’m going to use the two helpers bundled with traq: traqtrans and traqeval:

traq -p client -d 2012-12-09 | traqtrans | traqeval

which gives me the total of hours I’ve been working so far:

2012-12-09
#project:0.73
#meeting:2.870277777777778
%%

Now I can combine this with standard unix utilities:

traq -p client -d 2012-12-09 | traqtrans | traqeval | \
grep '#' | cut -d':' -f2 | paste -sd+ - | bc
# 3.600277777777778 

It’s a small step to interface with online time tracking services now - but I’m in complete control.

closing note

If you are a freelancer or an employee who likes to be in control of what data is being tracked this might be something for you. Check out the git repository, the installation is only four lines and I’d love your feedback.

© Raphael Randschau 2010 - 2022 | Impressum