I don’t think it’s possible to use a date for the purpose you want.
calculations, operations and the like involving given are famous for obtaining a certain level of inherent 'complexity'.
I think you should broaden the scope of the question and ask yourself:
'It is possible to have a script that runs every 1 hour ?'
There are several ways to do this, I believe that one of the simplest (I will cite it as an example only for which you test) is using an appropriate library. The Twisted is an event-guided library that can be used to execute codes at intervals of time:
from twisted.internet import reactor, task
from os.path import getsize
FILE = '/var/log/syslog'
def monitor(lastsize = [-1])
size = getsize(FILE)
if size <> lastsize[0]:
print 'O tamanho do arquivo agora é %d kilobytes (%d bytes)' % \
(round(size / 1024.0), size)
lastsize[0] = size
if __name__ == '__main__'
print 'Checando a cada um minuto o tamanho do arquivo "%s".' % FILE
print 'Atenção: esse programa NUNCA termina.'
l = task.LoopingCall(monitor)
l.start(1.0)
reactor.run()
This code for example checks the file size every 1 second. However the use of a library as large and complex as this just to use a simple functionality NAY is recommended, it would be like using a rocket to kill a mosquito.
For a solution implemented by itself I strongly recommend that read this article posted in Python Brazil. There is demonstrated 3 examples of how to execute codes at predetermined intervals in a simple and well explained way.
I hope I’ve helped.
Thank you very much Rickadt, that’s exactly what I was looking for.
– Andre Batista