Whamcloud - gitweb
LU-11971 utils: Send file creation time to clients
[fs/lustre-release.git] / lustre / doc / lfs-find.1
1 .TH lfs-find 1 "2018-01-24" Lustre "user utilities"
2 .SH NAME
3 lfs-find \- Lustre client utility to list files with specific attributes
4 .SH SYNOPSIS
5 .B lfs find \fR<\fIdirectory\fR|\fIfilename \fR...>
6       [[\fB!\fR] \fB--atime\fR|\fB-A\fR [\fB-+\fR]\fIn[smhdwy]\fR]
7 [[\fB!\fR] \fB--blocks\fR|\fB-b\fR [\fB+-\fR]\fIn\fR]
8       [[\fB!\fR] \fB--btime\fR|\fB--Btime\fR|\fB-B\fR [\fB+-\fR]\fIn[smhdwy]\fR]
9       [[\fB!\fR] \fB--ctime\fR|\fB-C\fR [\fB+-\fR]\fIn[smhdwy]\fR]
10       [[\fB!\fR] \fB--component-count|\fB--comp-count\fR [\fB+-\fR]\fIn\fR]
11       [[\fB!\fR] \fB--component-end|\fB--comp-end\fR|\fB-E\fR [\fB+-\fR]\fIn\fR[\fBKMGTPE\fR]]
12       [[\fB!\fR] \fB--component-flags|\fB--comp-flags\fR <[^]\fIflag\fB,\fR...>]
13       [[\fB!\fR] \fB--component-start|\fB--comp-start\fR [\fB+-\fR]\fIn\fR[\fBKMGTPE\fR]]
14       [[\fB!\fR] \fB--extension-size|\fB-z\fR [\fB+-\fR]\fIn\fR[\fBKMG\fR]]
15       [[\fB!\fR] \fB--gid\fR|\fB-g\fR|\fB--group\fR|\fB-G\fR <\fIgname\fR>|<\fIgid\fR>]
16       [[\fB!\fR] \fB--layout\fR|\fB-L mdt\fR,\fBraid0\fR,\fBreleased\fR]
17       [[\fB!\fR] \fB--foreign\fR [<\fItype\fR>]]
18 [[\fB!\fR] \fB--gid\fR|\fB-g\fR|\fB--group\fR|\fB-G\fR <\fIgname\fR>|<\fIgid\fR>]
19       [[\fB!\fR] \fB--layout\fR|\fB-L mdt\fR,\fBraid0\fR,\fBreleased\fR]
20 [\fB--lazy\fR]
21       [\fB--maxdepth\fR|\fB-D\fI n\fR]
22 [[\fB!\fR] \fB--mdt\fR|\fB--mdt-index\fR|\fB-m\fR <\fIuuid\fR|\fIindex\fR,...>]
23       [[\fB!\fR] \fB--mdt-count\fR|\fB-T\fR [\fB+-\fR]\fIn\fR]
24 [[\fB!\fR] \fB--mdt-hash\fR|\fB-H <\fIhashtype\fR>]
25       [[\fB!\fR] \fB--mirror-count|\fB-N\fR [\fB+-\fR]\fIn\fR]
26 [[\fB!\fR] \fB--mirror-state\fR <[^]\fIstate\fR>]
27       [[\fB!\fR] \fB--mtime\fR|\fB-M\fR [\fB-+\fR]\fIn[smhdwy]\fR]
28 [[\fB!\fR] \fB--name\fR|\fB-n <\fIpattern\fR>]
29       [[\fB!\fR] \fB--newer\fR[\fBXY\fR] <\fIreference\fR>]
30       [[\fB!\fR] \fB--ost\fR|\fB-O\fR <\fIindex\fR,...>]
31 [[\fB!\fR] \fB--pool\fR <\fIpool\fR>]
32 [\fB--print\fR|\fB-P\fR]
33       [\fB--print0\fR|\fB-0\fR]
34 [[\fB!\fR] \fB--projid\fR |<\fIprojid\fR>]
35       [[\fB!\fR] \fB--size|\fB-s\fR [\fB-+\fR]\fIn\fR[\fBKMGTPE\fR]]
36 [[\fB!\fR] \fB--stripe-count|\fB-c\fR [\fB+-\fR]\fIn\fR]
37       [[\fB!\fR] \fB--stripe-index|\fB-i\fR \fIn\fR,...]
38 [[\fB!\fR] \fB--stripe-size|\fB-S\fR [\fB+-\fR]\fIn\fR[\fBKMG\fR]]
39       [[\fB!\fR] \fB--type\fR|\fB-t\fR {\fBbcdflps\fR}]
40 [[\fB!\fR] \fB--uid\fR|\fB-u\fR|\fB--user\fR|\fB-U
41 <\fIuname\fR>|<\fIuid>\fR]
42 .SH DESCRIPTION
43 .B lfs find
44 is similar to the standard
45 .BR find (1)
46 utility and is used to list files and directories with specific attributes,
47 both regular POSIX attributes such as ownership, timestamps, and size using
48 the same options as
49 .BR find (1),
50 as well as Lustre-specific attributes such as stripe count and size,
51 OST and MDT location, and composite layout attributes.
52 .SH OPTIONS
53 .TP
54 .BR --atime | -A
55 File was last accessed \fIn\fR*24 hours ago (if no units are given),
56 or \fIn\fR*\fBs\fReconds, \fBm\fRinutes, \fBh\fRours, \fBd\fRays,
57 \fBw\fReeks, or \fBy\fRears ago within a margin of error of 24h,
58 or smaller if a unit is specified.  Multiple units can be specified,
59 for example \fB8h20m\fR is equivalent to \fB500m\fR.  If multipe units
60 are specified, the margin of error is based on the smallest unit used, so
61 .B -atime 3d
62 has a margin of error of one day, while
63 .B -atime 72h
64 has a margin of error of one hour.
65 .TP
66 .BR --blocks | -b
67 Blocks allocated by the file is \fIn\fR Kibibytes (if no units are given),
68 \fIn\fR 512-byte \fBb\fRlocks, or \fBK\fRibi-, \fBM\fRebi-, \fBG\fRibi-,
69 \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-bytes if that suffix is given.
70 .TP
71 .BR --btime | --Btime | -B
72 File was created \fIn\fR*24 hours ago, see
73 --atime
74 for full details and options.
75 .TP
76 .BR --ctime | -C
77 File's status was last changed \fIn\fR*24 hours ago, see
78 --atime
79 for full details and options.
80 .TP
81 .BR --component-count | --comp-count
82 The file has \fIn\fR components in its layout.
83 .TP
84 .BR --component-end | --comp-end
85 The file has component end offset \fIn\fR (in bytes) for any component.
86 .TP
87 .BR --component-flags | --comp-flags
88 The file has components with the specified
89 .I flag
90 set.  If
91 .BI ^ flag
92 is used, print only components not matching
93 .IR flag .
94 Multiple flags can be specified, separated by commas.  Valid flag names are:
95 .RS 1.2i
96 .TP
97 .B init
98 Component has been initialized (has allocated OST objects).
99 .TP
100 .B stale
101 Replicated (mirrored) components that do not have up-to-date data.  Stale
102 components will not be used for read or write operations, and need to be
103 resynched using
104 .B lfs mirror resync
105 before they can be accessed again.
106 .TP
107 .B prefer
108 Replicated (mirrored) components that are preferred for read or write.
109 For example, because they are located on SSD-based OSTs, or are more
110 local on the network to clients.
111 .RE
112 .TP
113 .BR --component-start | --comp-start
114 The file has component start offset \fIn\fR (in bytes) for any component.
115 .TP
116 .BR --foreign
117 File has a foreign (non-Lustre/free format) layout and is of the given
118 .IR type ,
119 if specified.  Presently only
120 .B none
121 or
122 .B daos
123 are defined types, though 32-bit numeric types can also be used.
124 .TP
125 .BR --gid | -g
126 File has specified numeric group ID.
127 .TP
128 .BR --group | -G
129 File belongs to specified group, numeric group ID allowed.
130 .TP
131 .BR --layout | -L
132 File has a layout of the given type, one of:
133 .RS 1.2i
134 .TP
135 .B raid0
136 Traditional Lustre RAID-0 striping format.
137 .TP
138 .B released
139 HSM-archived files that are not resident in the filesystem.
140 .TP
141 .B mdt
142 Files that have the first data component on an MDT.
143 .RE
144 .TP
145 .BR --lazy
146 Use file size and blocks from MDT, if available, to avoid extra RPCs.
147 .TP
148 .BR --maxdepth
149 Limits find to decend at most \fIn\fR levels of directory tree.
150 .TP
151 .BR --mdt | --mdt-index | -m
152 File or directory inode is located on the specified MDT(s).
153 .TP
154 .BR --mdt-hash | -H
155 DNE striped directory uses the given filename hashing function, one of:
156 .RS 1.2i
157 .TP
158 .B fnv_1a_64
159 The Fowler\-Noll\-Vo hash function, which is a simple and efficient hash.
160 .TP
161 .B all_char
162 Simple hash function that sums all of the characters in the filename.
163 This is mostly for testing, or if it is known that filenames will use
164 sequential filenames.
165 .RE
166 .TP
167 .BR --mdt-count | -T
168 The DNE striped directory has the given number of MDT shards.
169 .TP
170 .BR --mirror-count | -N
171 The file has \fIn\fR mirrors in its layout.
172 .TP
173 .BR --mirror-state
174 The file has a state of
175 .I state.
176 If
177 .BI ^ state
178 is used, print only files not matching
179 .IR state.
180 Only one state can be specified. Valid state name is:
181 .RS 1.2i
182 .TP
183 .B ro
184 The mirrored file is in read-only state. All of the mirrors contain
185 the up-to-date data.
186 .TP
187 .B wp
188 The mirrored file is in a state of being written.
189 .TP
190 .B sp
191 The mirrored file is in a state of being resynchronized.
192 .RE
193 .TP
194 .BR --mtime | -M
195 File's data was last modified \fIn\fR*24 hours ago, see
196 --atime
197 for full details and options.
198 .TP
199 .BR --name | -n
200 Filename matches the given filename, or regular expression using
201 standard
202 .BR glob (7)
203 file name regular expressions and wildcards.
204 .TP
205 .BR -newer [ XY "] " \fIreference
206 Succeeds if timestamp \fIX\fR of the file being considered is newer
207 than timestamp \fIY\fR of the file
208 .IR reference .
209 The letters \fIX\fR and \fIY\fR can be any of the following letters:
210
211 .TS
212 ll
213 ll
214 ll
215 ll
216 llw(2i).
217 a       The access time of the file \fIreference\fR
218 b|B     The birth time of the file \fIreference\fR
219 c       The inode status change time of \fIreference\fR
220 m       The modification time of the file \fIreference\fR
221 t       \fIreference\fR is interpreted directly as a time
222 .TE
223
224 Some combinations are invalid; for example, it is invalid for
225 .I X
226 to be
227 .IR t .
228 Specifying
229 .B -newer
230 is equivalent to
231 .BR -newermm .
232 When
233 .IR reference
234 is interpreted directly as a time, currently it must be in one of the
235 following formats: "%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M", "%Y-%m-%d",
236 "%H:%M:%S", "%H:%M", to represent year, month, day, hour, minute, seconds,
237 with unspecified times at the start of that minute or day, unspecified dates
238 being "today", and "@%s" or "%s" the seconds since the Unix epoch (see
239 .BR strftime (3)
240 for details of the time formats).  Otherwise, it will report an error.
241 If you try to use the birth time of a reference file, and the birth
242 time cannot be determined, a fatal error message results.  If you
243 specify a test which refers to the birth time of files being examined,
244 this test will fail for any files where the birth time is unknown.
245 .TP
246 .BR --ost | -O
247 File has an object on the specified OST(s).  The OST names can be specified
248 using the whole OST target name, or just the OST index number. If multiple
249 OSTs are given in a comma-separated list, the file may have an object on
250 any of the given OSTs.  Specifying multiple OSTs allows scanning the
251 filesystem only once when migrating objects off multiple OSTs for evacuation
252 and replacement using
253 .BR lfs-migrate (1).
254 .TP
255 .BR --pool
256 Layout was created with the specified
257 .I pool
258 name.  For composite files, this may match the pool of any component.
259 .BR --print | -P
260 Prints the file or directory name to standard output if it matches
261 all specified parameters, one file per line with a trailing linefeed.
262 This is the default behaviour for any matching files.
263 .TP
264 .BR --print0 | -0
265 Print full file name to standard output if it matches the specified
266 parameters, followed by a NUL character.  This is for use together with
267 .BR xargs (1)
268 with the
269 .B -0
270 option to handle filenames with embedded spaces or other special characters.
271 .TP
272 .BR --projid
273 File has specified numeric project ID.
274 .TP
275 .BR --size | -s
276 File size is \fIn\fR bytes, or \fBK\fRibi-, \fBM\fRebi-,
277 \fBG\fRibi-, \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-bytes if a
278 suffix is given.
279 .TP
280 .BR --stripe-count | -c
281 File has \fIn\fR stripes allocated.  For composite files, this
282 matches the stripe count of the last initialized component.
283 .TP
284 .BR --stripe-index | -i
285 File has stripe on OST index \fIn\fR.  Multiple OST indices can be
286 specified in a comma-separated list, which indicates that the file
287 has a stripe on \fIany\fR of the specified OSTs.  This allows a
288 single namespace scan for files on multiple different OSTs, if there
289 are multiple OSTs that are being replaced.
290 .TP
291 .BR --stripe-size | -S
292 Stripe size is \fIn\fR bytes, or \fBK\fRibi-, \fBM\fRebi-,
293 \fBG\fRibi-, \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-abytes if a
294 suffix is given.  For composite files, this matches the stripe
295 size of the last initialized non-extension component.
296 .TP
297 .BR --extension-size | --ext-size | -z
298 Extension size is \fIn\fR bytes, or \fBK\fRibi-, \fBM\fRebi-,
299 \fBG\fRibi-, \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-abytes if a
300 suffix is given.  For composite files, this matches the extension
301 size of any extension component.
302 .TP
303 .BR --type | -t
304 File has type: \fBb\fRlock, \fBc\fRharacter, \fBd\fRirectory,
305 \fBf\fRile, \fBp\fRipe, sym\fBl\fRink, or \fBs\fRocket.
306 .TP
307 .BR --uid | -u
308 File has specified numeric user ID.
309 .TP
310 .BR --user | -U
311 File owned by specified user, numeric user ID also allowed.
312 .SH NOTES
313 Specifying \fB!\fR before an option negates its meaning (\fIfiles
314 NOT matching the parameter\fR). Using \fB+\fR before a numeric
315 value means 'more than \fIn\fR', while \fB-\fR before a numeric value
316 means 'less than \fIn\fR'.  If neither is used, it means 'equal to
317 \fIn\fR', within the bounds of the unit specified (if any).
318 .PP
319 Numeric suffixes are in binary SI (power-of-two) units.
320 .PP
321 For compatibility with
322 .BR find (1)
323 it is possible to specify long options with either a single or double
324 leading dash.
325 .PP
326 The order of parameters does not affect how the files are matched.
327 .B lfs find
328 will first scan the directory for any specified filename, and then fetch
329 MDT inode attributes for each matching filename.  If it can make a
330 positive or negative decision for a file based only on the MDT attributes
331 (e.g.  newer than specified time, user/group/project ID) it will not fetch
332 the OST object attributes for that file.
333 .SH EXAMPLES
334 .TP
335 .B $ lfs find /mnt/lustre
336 Efficiently lists all files in a given directory and its subdirectories,
337 without fetching any file attributes.
338 .TP
339 .B $ lfs find /mnt/lustre -mtime +30 -type f -print
340 Recursively list all regular files in given directory more than 30 days old.
341 .TP
342 .B $ lfs find /mnt/lustre/test -o OST0002,OST0003 -print0 | lfs_migrate -y
343 Recursively find all files in
344 .B test
345 that have objects on OST0002 or OST0003 and migrate them to other OSTs.  See
346 .BR lfs_migrate (1)
347 for more details.
348 .TP
349 .B $ lfs find -name "*.mpg" --component-count +3 /mnt/lustre
350 Recursively list all files ending with
351 .B .mpg
352 that have more than 3 components.
353 .TP
354 .B $ lfs find --component-flags=init,prefer,^stale /mnt/lustre
355 Recursively list all files that have at least one component with both 'init'
356 and 'prefer' flags set, and doesn't have flag 'stale' set.
357 .TP
358 .B $ lfs find --mirror-count +2 /mnt/lustre
359 Recursively list all mirrored files that have more than 2 mirrors.
360 .TP
361 .B $ lfs find ! --mirror-state=ro /mnt/lustre
362 Recursively list all out-of-sync mirrored files.
363 .TP
364 .B $ lfs find ! --foreign=daos /mnt/lustre
365 Recursively list all but foreign files/dirs of
366 .B daos
367 type.
368 .SH BUGS
369 The
370 .B lfs find
371 command isn't as comprehensive as
372 .BR find (1).
373 In particular, it doesn't support complex boolean expressions with
374 .B -o
375 (logical OR), only logical AND of all expressions.  The order that parameters
376 are specified does not affect how the files are matched.
377 .SH AUTHOR
378 The
379 .B lfs
380 command is part of the Lustre filesystem.
381 .SH SEE ALSO
382 .BR lfs (1),
383 .BR lfs-getstripe (1),
384 .BR lfs-getdirstripe (1),
385 .BR lfs-migrate (1),
386 .BR lfs_migrate (1),
387 .BR lustre (7)
388 .BR xargs (1)