File date attribute

B

Bruce R Graham

Hi: am a Newbie and this is my first script:
We were recently burgled and had our computers stolen. Easy to replace,
but the data that was lost is years and years of work. I've
investigated offsite data backup but it seems expensive. In any case,
the data we have is not volumous.
Rather, would like to send emails of files to a backup address at
gmail.
So, this is my plan:
Run a script in cron.daily. The script should check a timestamp placed
by the last occurrence of that script. Then check my home folder for
files modified between that timestamp and now. Then send those files
off to gmail.
I have most of the pieces in place, except I can't find out how to
retrieve the date modified attribute of a file. Does anybody know how
to do that?
I'll post the full script when I'm done in case there is anybody who
would like to use it.
Kindest,
BG
 
S

Sybren Stuvel

Bruce R Graham enlightened us with:
Run a script in cron.daily. The script should check a timestamp
placed by the last occurrence of that script. Then check my home
folder for files modified between that timestamp and now. Then send
those files off to gmail.
I have most of the pieces in place, except I can't find out how to
retrieve the date modified attribute of a file. Does anybody know
how to do that?

man find. You can even tell it to list all files older than a
reference file.

Sybren
 
F

Fredrik Lundh

Bruce said:
I have most of the pieces in place, except I can't find out how to
retrieve the date modified attribute of a file. Does anybody know how
to do that?

t = os.path.getmtime(filename)

returns the timestamp as seconds since the epoch. see the "time" and
"datetime" modules for ways to convert this to other formats (if needed).

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,951
Messages
2,570,113
Members
46,698
Latest member
alexxx

Latest Threads

Top