I am using pysftp to logon to an ftp site. On the remote ftp site, there is a directory. I want to check the timestamp of the files and they are greater than 4 hours from system date/time, then I can assume the files stopped growing and I can move them somewhere else.
I just need help with: "I want to check the timestamp of the files and they are greater than 4 hours from system date/time"
for f in os.listdir(path): mode = int(os.stat(os.path.join(path, f)).st_ctime) dicter[f] = mode
This example puts the files in the current directory into a dictionary with the files timestamps as the value and the filename as the key. Then you can check the current timestamp against its timestamp for greater value than 4 hours. http://docs.python.org/2/library/stat.html Note that on windows its creation time, and on linux/unix its last modification time.
I haven't tested your sample code yet but I wanted to ask if this is going to reference the remote servers directory?? From my painful experience, os.path references my local machine where the script will be run from.
How will your script know I want to pull from the remote ftp server machine and not the local machine where the script is being executed from?
I have little experience with running scripts from remote servers. I think others would be best suited to answer that question. I could only assume though, that it would be similar except using the ftp file listing.