简体   繁体   English

通过使用os.walk减少硬盘驱动器的寿命

[英]reduction in the lifetime of a hard drive from using os.walk

Is there any problem with running the following script on a timer over a whole external disk drive? 在整个外部磁盘驱动器上的计时器上运行以下脚本是否有问题?

EXTERNAL_DRIVE_DIRECTORY = "E:\Files"
# get all of the files in a top level directory of a hard drive
def get_set_of_all_files():
    set_of_files = set()
    for root, dirs, files in os.walk(EXTERNAL_DRIVE_DIRECTORY):
        for f in files:
            # get file name without file extension
            f = os.path.splitext(f)[0]
            set_of_files.add(f)
    return set_of_episodes

The idea is to check all of the files on the hard drive against another set which has files that may or may not be in the hard drive. 这样做的目的是将硬盘驱动器上的所有文件与另一套文件进行检查,该另一套文件包含可能在硬盘驱动器中或可能不在硬盘驱动器中的文件。 Therefore the script may be running at time intervals (say, every 10 minutes). 因此,脚本可能每隔一定时间(例如,每10分钟)运行一次。

Will this be incredibly taxing on the hard drive? 这会给硬盘带来难以置信的负担吗? I have heard that disk can only read/write so many times, so it seems like this might reduce the life of the disk. 我听说磁盘只能读/写很多次,所以看来这可能会减少磁盘的使用寿命。 Is the reduction in life you would see from this code unusually large? 您从此代码中看到的寿命减少会异常大吗?

It depends on operating system, filesystem and amount of free memory. 它取决于操作系统,文件系统和可用内存量。
I can speak only for UNIX-based OSes - most of them will try to cache metadata for recently accessed files in memory on first run and most likely won't even issue a request to hard drive on subsequent runs. 我只能说基于UNIX的操作系统-他们中的大多数会在第一次运行时尝试将最近访问的文件的元数据缓存在内存中,并且很可能甚至在后续运行时都不会向硬盘驱动器发出请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM