noatime mount and find command

User avatar
witek
Posts: 233
Joined: 16. Nov 2009, 13:41
Location: Poland.Łódź

noatime mount and find command

Post by witek » 30. Nov 2010, 22:39

I`ve added an entry regarding /tmp cleanup. Another method often used is using find, ie:

Code: Select all

#!/bin/bash
find /tmp -type f -atime +5 -exec rm {} \\;
I don`t understand one thing here: the filesystem in Salix is mounted with noatime option by default. Does it influence find -atime behaviour? I tested and it looks that find is able to see access time but why should it if mounted with noatime? Or maybe it depends on the type of filesystem (I`m using XFS)

User avatar
gapan
Salix Wizard
Posts: 5490
Joined: 6. Jun 2009, 17:40

Re: notime mount and find command

Post by gapan » 30. Nov 2010, 22:44

I would advise against removing files from /tmp with a cronjob. There are files in there that are actually needed in a running session. The safest way to do it would be during shutdown by adding the appropriate entries in rc.local_shutdown. Or by mounting /tmp in RAM with tmpfs in the first place as I'm doing.
Image
Image

User avatar
thenktor
Salix Wizard
Posts: 2426
Joined: 6. Jun 2009, 14:47
Location: Franconia
Contact:

Re: noatime mount and find command

Post by thenktor » 30. Nov 2010, 22:46

File access time still is updated when the files are modified but not if the files are read.
If a file system has been mounted with this option, reading accesses to the file system will no longer result in an update to the atime information associated with the file like we have explained above. The importance of the noatime setting is that it eliminates the need by the system to make writes to the file system for files which are simply being read. Since writes can be somewhat expensive, this can result in measurable performance gains. Note that the write time information to a file will continue to be updated anytime the file is written to.
source: http://tldp.org/LDP/solrhe/Securing-Opt ... sec73.html
Image
burnCDDA (burns audio CDs)
geBIERt (German beer blog)

User avatar
witek
Posts: 233
Joined: 16. Nov 2009, 13:41
Location: Poland.Łódź

Re: noatime mount and find command

Post by witek » 30. Nov 2010, 22:48

@gapan:
As you can read in what I`ve written in the wiki I`m modifying rc.S, not using cron. But I wonder aboyt noatime and find by the way.
Last edited by witek on 30. Nov 2010, 22:49, edited 1 time in total.

Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: noatime mount and find command

Post by Shador » 30. Nov 2010, 22:48

witek wrote:I don`t understand one thing here: the filesystem in Salix is mounted with noatime option by default. Does it influence find -atime behaviour?
"noatime" doesn't mean there is no atime at all. It just means the access time of files isn't updated on access.
I didn't confirm this but by common sense I assume that it's updated together with ctime and mtime even though "noatime" is activated.
So with noatime enabled you're actually using the ctime and not the atime.

Seems thenktor was faster. :D
Image

User avatar
witek
Posts: 233
Joined: 16. Nov 2009, 13:41
Location: Poland.Łódź

Re: noatime mount and find command

Post by witek » 30. Nov 2010, 22:52

Thanks for clarifying this issue. What do you think about the method I described in the wiki? Why isn`t /tmp completely wiped during boot in Salix by default?

User avatar
gapan
Salix Wizard
Posts: 5490
Joined: 6. Jun 2009, 17:40

Re: noatime mount and find command

Post by gapan » 30. Nov 2010, 22:52

witek wrote:@gapan:
As you can read in what I`ve written in the wiki I`m modifying rc.S, not using cron. But I wonder aboyt noatime and find by the way.
You're specifically mentioning crontab and listing a script that you're proposing to be run from crontab. Not a good idea.
Image
Image

User avatar
thenktor
Salix Wizard
Posts: 2426
Joined: 6. Jun 2009, 14:47
Location: Franconia
Contact:

Re: noatime mount and find command

Post by thenktor » 30. Nov 2010, 22:54

witek wrote:Why isn`t /tmp completely wiped during boot in Salix by default?
Because there is no need to do it ;)
Image
burnCDDA (burns audio CDs)
geBIERt (German beer blog)

User avatar
witek
Posts: 233
Joined: 16. Nov 2009, 13:41
Location: Poland.Łódź

Re: noatime mount and find command

Post by witek » 30. Nov 2010, 22:58

gapan wrote: You're specifically mentioning crontab and listing a script that you're proposing to be run from crontab. Not a good idea.
I must have been misunderstood: I meant to modify rc.S (crontab is only a possibility not described in my entry). I hope now it reads better.

User avatar
gapan
Salix Wizard
Posts: 5490
Joined: 6. Jun 2009, 17:40

Re: noatime mount and find command

Post by gapan » 30. Nov 2010, 23:15

No, it really doesn't. Crontab is simply not a safe option here and it should not be mentioned at all. Also, editing rc.S or any other standard rc script is not advisable. An update of the sysvinit-scripts will wipe all edits. That's what rc.local and rc.local_shutdown are for.
Image
Image

Post Reply