5
1
I’m sorry if this question is really stupid, but this is basically what I have been thinking about constantly. Suppose I run:
: cat ./somefile.txt
A few hundred times a second. How much faster is my hard drive going to die?
5
1
I’m sorry if this question is really stupid, but this is basically what I have been thinking about constantly. Suppose I run:
: cat ./somefile.txt
A few hundred times a second. How much faster is my hard drive going to die?
20
Seven. But seriously, it's hard enough to know how long a disk will last while idling let alone under heavy load. There's no answer other than to say it will probably wear the disk faster.
The better argument against this is it would generally be quite slow. Why would you need to hammer the disk like that?
If you're looking to find out when something changes, perhaps look at inotify which is a kernel-based file event system that can call some code when something happens, negating the need to hammer the disk.
There are wrappers like pyinotify to make things easier.
1+1 for the pointer to inotify. I hadn't heard of it before and it looks like a useful tool. – Amelio Vazquez-Reina – 2011-07-08T14:16:31.623
19
It may have no effect at all, depending on the size of somefile.txt
- if it's small enough for the kernel to cache it in RAM, the file will only be read once from disk and subsequent iterations will retrieve it from the cache.
Even if running that command repeatedly does have an effect on your drive's lifetime, it will be due to the file being read repeatedly. Whether you use cat
or some other program to read it is completely irrelevant.
1I guess nowadays there are very few files you would want to cat
large enough not to be cached completely. So indeed, only the first time the disk is going to feel it. – Joey – 2011-07-07T14:28:47.007
3
This reminds me of that study Google did about Harddrives. Since they go through a lot of harddrives, they did an informal study to see if there was any significant correlation between the lifetime of a HD and a list of factors that include temperature, power cycles, activity levels, etc. The only significant factor they found was age, I believe. The study is called "Failure Trends in..." something something.
I wouldn't worry too much about HD usage eating your drive.
Why would you call cat a few hundred times a second to begin with? Are you trying to parse something? – 8BitsOfGeek – 2011-07-07T13:22:27.970
4FWIW, running
: cat somefile.txt
does not runcat
. The:
built-in does nothing at all. – user1686 – 2011-07-07T13:50:19.607: cat somefile.txt > otherfile.txt
creates otherfile. – Blub – 2011-07-07T13:58:31.62738It's usually a wasted effort -- they never come until they hear the can opener. – Daniel R Hicks – 2011-07-07T17:46:13.987
@Blub, actually your command does very little
– dr jimbob – 2011-07-07T18:28:53.043: cat somefile.txt > otherfile.txt
will not copy the contents ofsomefile.txt
tootherfile.txt
;otherfile.txt
will be present after the command, but will be empty (even if it originally had contents).: \
cat somefile.txt > otherfile.txt`will copy the contents of
somefile.txtto
otherfile.txt` without displaying the output. See: http://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html and http://stackoverflow.com/questions/3224878/what-is-the-purpose-of-the-colon-gnu-bash-builtinDepending on the file, it is also possible that somefile.txt is cached by the OS. This way when you do cat, there is no hard drive access at all (it is taken from your RAM), so you will not change the life span of the hard drive. – earlNameless – 2011-07-20T19:19:25.093