Q:

How to Track Software Run/Output

Background:
I'm begining to forge my way into more of a software engineering role at work.  I have no computer science background and have learned to program some high level languages on my own (mostly R, python, and ruby). And before I start to find my own solutions to problems, I want to know best practices for keeping tack of last runs of the program.
Specifically, I'm writing a program that will clean data in a database (find missing data, imputation, etc...).  It needs to know when it was last run so it does not retrieve too much data.
Question:
How do I best keep track of previous code runs?
I'm writing production level code.  These scripts and functions will be run automatically (maybe a nightly or weekly basis), and the results will be output to a file.  Each of these programs will depend on when it was run last.  I can see this dealt with a few ways.

The output file name (or a diagnostic file name) contains the last date/time it was run.  I.e. 'output_file_2014_07_11_01_00_04.txt'  From this name, the program can determine when it was last run.
Keep a separate info file that the program just appends the last run time to a list of run times.

These solutions seem prone to problems.  Is there a more secure and efficient method for recording/reading the last run date?

A:

I like the idea of putting it in the filename. That binds the run time to the actual data. If you keep the run time in a separate file, data can separated from the meta-data (i.e. the run time).
This works in a trusted environment. If accidental or malicious vandalism is a concern, like changing a filename is a problem, then a lot other things become problematic too. 
A third alternative is to create a "header" or comment section in the data file itself. The the run time in the header. When you read the data, your skip can either skip the header and go straight for the data, or examine the header and extract the meta-data (i.e. run time or other attributes). 
This approach has the advantage that (a) the meta-data and the data are kept together and (b) you can include more meta-data than just the run time. This approach has the disadvantage that any program reading the data must first skip the header. For an example of this approach, see the Attribute-Relation File Format (ARFF) at http://www.cs.waikato.ac.nz/ml/weka/arff.html

