Every freelancer uses some kind of accounting-package to keep track of the billable time, but, given multiple machines, on-site gigs and the like, keeping track is not always that easy, isn’t it? For that reason, I came up with a really simple combination of two Perl-scripts.
The first one, start_record.pl, writes the epoch-seconds to a temporary file and prints some information to the terminal-window.
Update: Thanks to Hebikai for pointing out a problem with the relative path, the scripts are using the environment-variable $HOME to determine the path now.
#!/usr/bin/perl
$HOME_dir = $ENV{HOME};
$DATA_dir = "$HOME_dir/work/time_control_stuff";
$start_time = time;
#print "Seconds: $start_time\n";
print "customer|topic\n";
print "Remarks: \n";
print localtime($start_time)."\n";
open(MY_HANDLE, ">$DATA_dir/time.log") or die "$0: something went wrong: $!\n";
print MY_HANDLE $start_time."\n";
close(MY_HANDLE);
The script assumes, that there is a directory called time_control_stuff in ~/work/. Its output should be copied or piped into a file, it records the time you started. If you want, feel free to modify the customer|topic and Remarks lines to taste.
If you are done with the task, the end_record.pl script comes into play.
#!/usr/bin/perl
$HOME_dir = $ENV{HOME};
$DATA_dir = "$HOME_dir/work/time_control_stuff";
$end_time = time;
open(MY_HANDLE, "$DATA_dir/time.log") or die "$0: something went wrong: $!\n";
while()
{
chop;
$start_time = $_;
}
$total_time = $end_time - $start_time;
$total_mins = $total_time/60;
$total_hours = $total_mins/60;
print "Start: ".localtime($start_time)."\n";
print "End: ".localtime($end_time)."\n";
print "Total: ".$total_time."\n";
print "Mins: $total_mins\n";
print "Hours: $total_hours\n";
print "\nBill: \n\n";
Its output is pretty much self-explanatory, copy or append to the same file and you are done.
I use an USB-stick to carry the scripts with me all the time. If I need to record billable time and don’t have access to one of my machines, these scripts are my way to go. I input the recorded data into my accounting-package as soon as I’m able to do so.
Granted, they could be a lot more sophisticated, but remember KISS (Keep It Simple S…) rules. Use the scripts as a starting-point for you “accounting on the road.”