[Tutor] Better way to check *nix remote file age?
Leam Hall
leamhall at gmail.com
Sat Jun 28 00:37:05 CEST 2014
On 06/27/14 06:10, Raúl Cumplido wrote:
> Hi,
>
> I would recommend also instead of doing an "ls -l" command doing
> something to retrieve only the information you need:
>
> /bin/ls -ls | awk '{print $7,$8,$9, $10}'
>
> Jun 27 10:36 my_file
>
>
> Then I would use timedelta instead where you can be more accurate with
> the dates (in the example if the file is older than 62 days):
> def too_old(text):
> month, day, year = (text[0], text[1],
> text[2] if ':' not in text[2] else
> datetime.datetime.now().year)
> time_difference = datetime.datetime.now() - datetime.datetime.strptime(
> "{0}{1}{2}".format(month, day, year), '%b%d%Y')
> return time_difference > datetime.timedelta(days=62)
Raúl, that looks interesting. Let me think through it.
Leam
--
http://31challenge.net
http://31challenge.net/insight
More information about the Tutor
mailing list