Sponsored Content
Top Forums Shell Programming and Scripting Need Help in ksh Script to list files older than 365 days from specified directories Post 302936819 by prasadn on Saturday 28th of February 2015 04:51:54 AM
Old 02-28-2015
Thanks very much Don for replying.

The below is the output

Code:
drwxrwxrwx   31 root     db2cadm        4096 Feb 27 02:21 /db/
drwxrwxrwx   26 root     system        12288 Feb 19 04:27 /db/backup/
drwxr-xr-x    6 srpsdba1 db2cadm        4096 Dec 22 01:08 /db/srpsdba1/db2dump/
drwxrwxr-x    2 srpsdba1 db2cadm         256 Mar 26 2014  /db/srpsdba1_2/db2dump/
drwxrwxrwx    6 srpsdba2 db2cadm        4096 Jan 13 22:00 /db/srpsdba2/db2dump/
drwxr-xr-x    4 srpsdba7 db2cadm        4096 Dec 18 15:12 /db/srpsdba7/db2dump/
drwxrwxrwx    4 srpsdbc  db2cadm        4096 Feb 23 03:03 /db/srpsdbc/db2dump/
drwxrwxrwx    4 srpsh1   db2cadm        8192 Feb 17 05:57 /db/srpsh1/db2dump/
drwxr-xr-x    2 srpssq1  db2cadm         256 Mar 12 2014  /db/srpsq1/db2dump/
drwxrwxrwx    4 srpssd3  db2cadm        4096 Feb 23 09:20 /db/srpssd3/db2dump/
drwxrwxrwx    4 srpssd5  db2cadm        4096 Feb 27 14:41 /db/srpssd5/db2dump/
drwxr-xr-x    2 srpsh1   db2cadm         256 Feb 27 2014  /db/srpssh1/db2dump/
drwxrwxrwx    4 srpssq1  db2cadm        8192 Feb 26 11:46 /db/srpssq1/db2dump/
drwxrwxrwx    5 srpssq2  db2cadm        8192 Feb 26 03:35 /db/srpssq2/db2dump/
drwxr-xr-x  397 bin      bin           16384 Jan 15 11:06 /home/
drwxrwxrwx   16 root     system         4096 Jan 12 17:34 /staging/
drwxrwxrwx   51 dba_srps ezcssgrp       8192 Feb 27 12:24 /staging/codedrops/

Yes you are correct if the script list's the older files from the sub directories also then only /home/ /db/ /staging/ should be fine.

Can you please kindly help me out.

Thanks once again
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, output, and code segments.

Last edited by Don Cragun; 02-28-2015 at 06:02 AM.. Reason: Add CODE and ICODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to remove files older than 30 days except directories

Hi, I need to remove files (*.trc) which are older than 30 days from one location. My problem is there I do not want to visit any of the directories at that location. I want to search files at that particular location only (need to skip directorys at that location). maxdepth option is there... (6 Replies)
Discussion started by: malaymaru
6 Replies

2. Red Hat

Find files older than 30 days in directories and delete them

Hi, I have dummies questions: My script here can find the files in any directories older than 30 days then it will delete the files but not the directories. I would like to also be able to delete the directories that hold old files more than 30 days not just the files itself. find . -type f... (2 Replies)
Discussion started by: lamoul
2 Replies

3. Shell Programming and Scripting

Script for parsing directories one level and finding directories older than n days

Hello all, Here's the deal...I have one directory with many subdirs and files. What I want to find out is who is keeping old files and directories...say files and dirs that they didn't use since a number of n days, only one level under the initial dir. Output to a file. A script for... (5 Replies)
Discussion started by: ejianu
5 Replies

4. Shell Programming and Scripting

List the files which are older than 7 days

Hi Frnds, I have to list the files which are older than 7 days in the given directory. it should consider only the files and should not show subdirectories. Thanks, Raja (3 Replies)
Discussion started by: smr_rashmy
3 Replies

5. Shell Programming and Scripting

script to remove files older than 60 days

Hi I need help in the script which looks at a contorl file which has a list of file names like xxxx.12345 and I want to take only xxxxx and search in a specific directory and remove the file if its older than 60 days I have written something like this.. but seems to be wrong... (1 Reply)
Discussion started by: antointoronto
1 Replies

6. Shell Programming and Scripting

Finding directories older than 5 days

Hello, Motive: Search all directories which are older than 5 days. Example: consider following directory structure: abc/dir1 abc/dir1/dir abc/dir2 abc/dir3 abc/dir3/temp Suppose dir1 and dir3 are 5 days older. Then I am looking for a command which lists abc/dir1 and abic/dir3 only so that... (4 Replies)
Discussion started by: mytempid07
4 Replies

7. UNIX for Dummies Questions & Answers

List files older that 7 days in a dir, excluding all subdirs

Hi, I would like to list all files, older than 7 days, in a directory, but exclude all subdirectories in the find command. If I use find . -type f -mtime +7 all files in the subdirs are also included. How can I exclude them? Regards, JW (6 Replies)
Discussion started by: jwbijl
6 Replies

8. UNIX for Dummies Questions & Answers

How to compress the directories which is older than 7 days?

Hi all, how to compress the directories which is older 7 days. If any one knows please help me this is urgent. Thanks in advance (3 Replies)
Discussion started by: rameshpagadala
3 Replies

9. Shell Programming and Scripting

List and Delete Files which are older than 7 days, but have white spaces in file name

I need to list and delete all files in current older which are olderthan 7 days. But my file names have white spaces. Before deleting I want to list all the files, so that I can verify.find . -type f -mtime +7 | xargs ls -l {} But the ls command is the working on the files which have white... (16 Replies)
Discussion started by: karumudi7
16 Replies

10. Shell Programming and Scripting

List files older than 10 days.

Hello all, I want to list the files older than 10 days. Currently am using find ./ -mtime +10 -exec ls -ltr {} \; command. But I want to execute the same command in 16 directories at a time and want an output asking to remove those file? Please help me to design the script. regards, Ajay (3 Replies)
Discussion started by: 02Ajay
3 Replies
NFS(5)							      BSD File Formats Manual							    NFS(5)

NAME
NFS -- Network File System SYNOPSIS
NFS DESCRIPTION
NFS is the standard UNIX file sharing protocol suite. MacOS supports version two, NFSv2 (RFC 1094), version three, NFSv3 (RFC 1813), and in addition for the client, version four, NFSv4 (RFC 3530). NFSv2 and NFSv3 also rely on adjunct protocols for mounting, Mountd (RFC 1094, RFC 1813) and for locking, NLM (OpenGroup XNFS). NFSv4 subsumes both mount and locking operations in to it's protocol. MacOS systems support TCP over IPv4 and IPv6. In addition for versions two and three of the protocol, UDP is supported over IPv4 and IPv6, however its use is dis- couraged. Version two of the protocol is considered legacy and should only be used if higher versions of the protocol are unavailable. MacOS Extended Attribute Considerations MacOS makes heavy use of extended attributes, resource forks, and possibly ACLs. NFSv2 and NFSv3 do not support these operations over the wire. The getting and setting of ACLs are not supported but extended attributes and resource forks for MacOS clients are supported by storing extended attributes and resource forks in an "Apple Double" (also known as a dot under bar file) files on the server. On the other hand NFSv4 can optionally support ACLs. And can optionally support the storing of resource forks and extended attributes as NFSv4 named attributes. Previous versions of NFSv4 on MacOS would use NFSv4 named attributes if supported by the server for storing extended attributes and resource forks, however this version of NFSv4 defaults to using "Apple Double" files. If a server exports files systems with both NFSv3 and NFSv4 (the usual default case) and supports named attributes as well, then there is a potential for data loss, since changing an extended attribute or resource fork from an NFSv3 client is not visible to an NFSv4 client and visa versa. If the server is known to only have NFSv4 clients or is only exporting file systems with NFSv4 then MacOS clients should use the namedattr option. See mount_nfs(8). If converting from NFSv3 to NFSv4 only with named attribute support, the following procedure can be use to convert the "Apple Double" files to NFSv4 named attributes. Be sure that the file system on the server has no other MacOS NFS mounts. Then allow one MacOS NFSv4 client that has been mounted with the namedattr mount option (mount -o vers=4,namedattr), to mount the export(s) on the server. Then at the mount point on the client run the dot_clean -m command. This will read the "Apple Double" files and convert them to native extended attributes on the server and then remove the "Apple Double" file. MacOS ACL support. ACLs (access control list) are enforced at the server not the client. As mentioned above NFSv3/NFSv2 do not support ACLs. So it is possible to get access or permission errors even though the BSD permission bits indicate that a file system operation should succeed. MacOS NFSv4 clients can optionally support ACLs if the acl or aclonly options are given at mount time. The reason that ACLs are not enabled by default is that there interpretation can be different from one server to another. Particularly in the way BSD mode bits are interpreted. A simplified explanation for MacOS, is that it interprets ACLs by running over the list of ACEs (access control entries) in order and if all requests for access have been granted and no request for access has been denied then the access is granted. If no request has been denied but some request have not been granted then fall back to the BSD access permissions. A complete description of ACLs can be found in "Appendix B, File System Details" in the File System Programming Guide. Also see acl, noacl, and aclonly in mount_nfs(8) for more details. Future version of MacOS may enable ACL support by default. NFSv4 Name mapping. Unlike NFSv3/NFSv2 identities for owners and groups are represented by strings instead of 32 bit numbers. Thus NFSv4 clients and servers have to convert these over the wire string identities to the local identities and local identities to strings. These strings are principally used in GETATTR, SETATTR, and ACEs for security identities. Note that the RPC credential is used for permission and access checking for whether an operation will be allowed. Those credentials are found in the RPC header, such as a kerberos identity that is associated with the RPC- SEC_GSS context. These strings are of the form "identity@NFSv4Domain", where the "NFSv4Domain" follows DNS domain naming conventions. MacOS NFSv4 name mapping rules. When processing identities by default we first check and see if the idenity string from the server is a string of digits if so we use that as the uid/gid to ask Open Directory to map that to a local idenitity. If that fails or the idenity string is not a string of digits we next check for well known names that NFSv4 supports. These names are of the form "identity@" with no domain part. If we match any of the following OWNER@ GROUP@ EVERYONE@ INTERACTIVE@ NETWORK@ DIALUP@ BATCH@ ANONYMOUS@ AUTHENTICATED@ SERVICE@ These identities are mapped to Open Directory internal identities. Along with any other identity that ends in an "@", which are mapped to nobody. These well known identities are used as generic security idenitifiers in ACEs. These identities are mapped back to the above strings when going back over the wire to the server. If the identites do not match the strings ending in "@" then we attempt to map the identities as follows. MacOS clients support a zero configuration option by not specifying a default NFSv4 domain. String identies coming from the server are handed as is to Open Directory to translate the string identity to the local identity. This works if the NFSv4 domain is the same as an Open Directory node name. Local identies are similarly translated to the fully scoped Open Directory names on the way out. If Open Directory returns an error in trying to map the identities we then by default try to use the following fall back idenities: root@any_domain wheel@any_domain nobody@any_domain nfsnobody@any_domain Root and wheel identities are translated by Open Directory with uid/gid of zero and nobody and nfsnobody are traslated to uid/gid of -2 (MacOS internal representation for the nobody uid/gid). This is useful in situations where the client and server do not share a common naming database. It is recommended where sites have a large number of MacOS clients, set their NFSv4 domain to be the LDAP node that is being used to bind Open Directory so that there is no other con- figuration needed for the Mac clients. For environments which have a different NFSv4 domain name from the bound LDAP node name, the NFSv4 domain name needs to be set by editing /etc/nfs.conf and adding the line nfs.client.default_nfs4domain = <my_nfsv4_domain> See nfs.conf(5). The rules for mapping are then as follows. If a string identity comes in over the wire whose domain portion matches the client's NFSv4 domain, then its stripped off and that unscoped name is this given to Open Directory to map to a local identity. On the way back to the server any Open Directory node name is stripped off and the NFSv4 domain name is appended. If the identity coming from the server does not match the NFSv4 domain name, then its passed to Open Directory as is and the rules described above for having no NFSv4 domain name set are followed. Examples The server has set its NFSv4 domain that is not the same as any MacOS client Open Directory node, so that the identity mapping is not set up correctly. Users will see output like the following example: 3-$ ls -l /tmp/mp total 16851 -rw-r--r-- 1 nobody nobody 29 Oct 12 2015 Foo.txt drwxr-xr-x 3 nobody nobody 4 Jan 31 16:27 Q102/ drwxrwxrwx 3 nobody nobody 7 Jan 24 16:59 acl/ -rw-r--r-- 1 nobody wheel 0 Feb 8 11:54 file1 -rw-r--r-- 1 root wheel 0 Feb 8 12:00 file2 -rw-r--r-- 1 nobody nobody 0 Feb 9 11:06 fooby drwx------ 2 nobody nobody 5 Sep 22 2015 keyring-GbeUpi/ drwx------ 2 65432 nobody 5 Sep 8 2015 keyring-OX5G6P/ Most of the mappings comeback as "nobody/nobody". Note "file1" comes back with group wheel. This is an example of fall back identity map- ping. Similarly for "file2" for both the user and group return root and wheel respectfully. The directory "keyring-OX5G6P" has ownership of 65432 this is because the server could not map that id locally and so sent it over the wire as a string of digits. After correcting the NFSv4 domain on the server we have: 4-$ ls -l /tmp/mp total 16851 -rw-r--r-- 1 lbricker staff 29 Oct 12 2015 Foo.txt drwxr-xr-x 3 lbricker staff 4 Jan 31 16:27 Q102/ drwxrwxrwx 3 lbricker staff 7 Jan 24 16:59 acl/ -rw-r--r-- 1 lbricker staff 0 Feb 8 11:54 file1 -rw-r--r-- 1 root nobody 0 Feb 8 12:00 file2 -rw-r--r-- 1 lbricker nobody 0 Feb 9 11:06 fooby drwx------ 2 lbricker staff 5 Sep 22 2015 keyring-GbeUpi/ drwx------ 2 65432 staff 5 Sep 8 2015 keyring-OX5G6P/ What is surprising is that file1 and file2's group is now nobody. The reason is that the server is sending those group ids as "root@<open_directroy_node>". Open Directory will not find that mapping so it will map it to nobody (had "wheel@<open_directory_node" had been used, wheel would have been returned). In the previous example the server sent "root@bogus.nfsv4.com". Open Directory will now return an error since it can not find a valid Open Directory node "bogus.nfsv4.com" and thus use the fall back to a gid of 0. Debugging NFSv4 name mapping can be done with the nfs4mapid command. See nfs4mapid(8). This allows testing of name/identity translations by using a system call into the kernel that calls the same routines as the MacOS nfs client uses. For example we determine the group transla- tions above. 83-$ sudo nfs4mapid -G root@nod.apple.com group root@nod.apple.com maps to id -2 mapping done through guid ABCDEFAB-CDEF-ABCD-EFAB-CDEFFFFFFFFE 84-$ sudo nfs4mapid -G wheel@nod.apple.com group wheel@nod.apple.com maps to id 0 mapping done through guid ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000 85-$ sudo nfs4mapid -G wheel@foobar.com group wheel@foobar.com maps to id 0 mapping done through guid ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000 86-$ sudo nfs4mapid -G root@foobar.com group root@foobar.com maps to id 0 mapping done through guid ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000 See Also "Appendix B, File System Details", File System Programming Guide, Apple, https://developer.apple.com. dot_clean(1), nfs.conf(5), nfs4mapid(8), mount_nfs(8), opendirectoryd(8), Standards [RFC1094] B. Nowicki, NFS: Network File System Protocol specification, RFC1094, March 1989, http://www.rfc-editor.org/info/rfc1094. [RFC1813] B. Callaghan, B. Pawlowski, and P. Staubach, NFS Version 3 Protocol Specification, RFC1813, June 1995, http://www.rfc- editor.org/info/rfc1813. [RFC3530] S. Shepler, B. Callaghan, D. Robinson, R. Thurlow, C. Beame, M. Eisler, and D. Noveck, Network File System (NFS) version 4 Protocol, RFC3530, April 2003, http://www.rfc-editor.org/info/rfc3530. [XNFS] Protocols for Interworking: XNFS, Version 3W, Open Group Technical Standard, February, 1998, ISBN: 1-85912-184-5. BSD
May 25, 2017 BSD
All times are GMT -4. The time now is 06:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy