Hi Expert's,
I need your assitance in tunning one script. I have a mount point where almost 4848008 files and 864739 directories are present. The script search for specific pattern files and specfic period then delete them to free up space. The script is designed to run daily and its taking around 3 complete days to complete. So the task of tunning came to me.
Initial the Script has 43 find command to delete files 5 find commands to delete the empty directory.
Two ways I took to tune this script.
1)Combine all seraching pattern/time to reduce the find command like below
So I got only 7 find command for files and one command for directory. I think(not tested the approach yet) this reduce the search and reduce the time too.
2) Since the first one has -exec command along with the find command what i think is it will take more time, So second approach what I have is finding the files which i need to delete and the delete it with the below loop.
So, What I request is please let me know the pros & cons on approach 1 & 2. Also please let me know find -exec will take more time or not.
Thanks
Senthil
Hi Frineds,
I want to delete a set of files which are older than 7 days from teh current date.I am totally enw to shell scripting, can anyone help me with a sample code to list out the files which are older and then remove them from the directory.
Please help
THanks
Viswa (5 Replies)
find /filearchive/ -type f -mtime +7 -exec rm weblogs*.log {} \;
This worked only if this comand is executed int he unix comand prompt, but when i put this in the shell script it is not recognizing the file.It says weblogs: No such file or directory
Am i doing anything wrong here ? (4 Replies)
Hi
I have a job that will be running nightly incremental backsup of a large directory tree.
I did the initial backup, now I want to write a script to verify that all the files were transferred correctly. I did something like this which works in principle on small trees:
diff -r -q... (6 Replies)
Hi,
As a a security audit, how can I proceed further with Fine tuning and Hardening the linux kernel... I am not sure with the steps how to proceed further... If i do some thing wrong, then its comes with the Kernel panic error. So, I am afraid, how to do the tuning with the kernel.. (1 Reply)
Hi all,
I try to write shell script to the below requirement.
I have Hard coded the oratab location and take the list of databases from oratab and find out archive log locations for each database,
and list more than 3 days old files for each location and purge those.
... (2 Replies)
Hello All,
I want to delete the files based on the days. like, Files available under directory /abc want to delete if they are older than 15 days.
Files available under directory /pqr want to delete if they are 7 days old and some files under directory /xyz should get deleted if they are... (5 Replies)
i would like to know how can i fine tune the following query since the cost of the query is too high ..
insert into temp temp_1 select a,b,c,d from xxxx
.. database used is IDS.. (1 Reply)
Hi,
I have this routine that reads a microsoft dhcp.netsh dump. Where it finds optionvalue 3 STRING "0.0.0.0"
Replace it with the router IP based on the network
!/usr/bin/perl
while ( <> )
{
if ( /\# NET / ) { $net = $'; $net =~ s///g; }
else
{
s/set optionvalue 3... (1 Reply)
Hi All,
I am looking forward to create a unix shell script to purge the files.
The requirement is:
1) Do df -k and check the current space occupied for the /a1 folder.
2) If the space consumed is greater than 90 %, delete all the DEF* files from a subfolder /a1/archive.
Example:
df... (4 Replies)
hi,
We have a huge directory that ha 5.1 Million files in it. We are trying to get the file name and modified timestamp of the most recent 3 years from this huge directory for a migration project.
However, the ls command (background process) to list the file names and timestamp is running for... (2 Replies)
Discussion started by: subbu
2 Replies
LEARN ABOUT MOJAVE
find2perl
FIND2PERL(1) Perl Programmers Reference Guide FIND2PERL(1)NAME
find2perl - translate find command lines to Perl code
SYNOPSIS
find2perl [paths] [predicates] | perl
DESCRIPTION
find2perl is a little translator to convert find command lines to equivalent Perl code. The resulting code is typically faster than
running find itself.
"paths" are a set of paths where find2perl will start its searches and "predicates" are taken from the following list.
"! PREDICATE"
Negate the sense of the following predicate. The "!" must be passed as a distinct argument, so it may need to be surrounded by
whitespace and/or quoted from interpretation by the shell using a backslash (just as with using find(1)).
"( PREDICATES )"
Group the given PREDICATES. The parentheses must be passed as distinct arguments, so they may need to be surrounded by whitespace
and/or quoted from interpretation by the shell using a backslash (just as with using find(1)).
"PREDICATE1 PREDICATE2"
True if _both_ PREDICATE1 and PREDICATE2 are true; PREDICATE2 is not evaluated if PREDICATE1 is false.
"PREDICATE1 -o PREDICATE2"
True if either one of PREDICATE1 or PREDICATE2 is true; PREDICATE2 is not evaluated if PREDICATE1 is true.
"-follow"
Follow (dereference) symlinks. The checking of file attributes depends on the position of the "-follow" option. If it precedes the
file check option, an "stat" is done which means the file check applies to the file the symbolic link is pointing to. If "-follow"
option follows the file check option, this now applies to the symbolic link itself, i.e. an "lstat" is done.
"-depth"
Change directory traversal algorithm from breadth-first to depth-first.
"-prune"
Do not descend into the directory currently matched.
"-xdev"
Do not traverse mount points (prunes search at mount-point directories).
"-name GLOB"
File name matches specified GLOB wildcard pattern. GLOB may need to be quoted to avoid interpretation by the shell (just as with using
find(1)).
"-iname GLOB"
Like "-name", but the match is case insensitive.
"-path GLOB"
Path name matches specified GLOB wildcard pattern.
"-ipath GLOB"
Like "-path", but the match is case insensitive.
"-perm PERM"
Low-order 9 bits of permission match octal value PERM.
"-perm -PERM"
The bits specified in PERM are all set in file's permissions.
"-type X"
The file's type matches perl's "-X" operator.
"-fstype TYPE"
Filesystem of current path is of type TYPE (only NFS/non-NFS distinction is implemented).
"-user USER"
True if USER is owner of file.
"-group GROUP"
True if file's group is GROUP.
"-nouser"
True if file's owner is not in password database.
"-nogroup"
True if file's group is not in group database.
"-inum INUM"
True file's inode number is INUM.
"-links N"
True if (hard) link count of file matches N (see below).
"-size N"
True if file's size matches N (see below) N is normally counted in 512-byte blocks, but a suffix of "c" specifies that size should be
counted in characters (bytes) and a suffix of "k" specifies that size should be counted in 1024-byte blocks.
"-atime N"
True if last-access time of file matches N (measured in days) (see below).
"-ctime N"
True if last-changed time of file's inode matches N (measured in days, see below).
"-mtime N"
True if last-modified time of file matches N (measured in days, see below).
"-newer FILE"
True if last-modified time of file matches N.
"-print"
Print out path of file (always true). If none of "-exec", "-ls", "-print0", or "-ok" is specified, then "-print" will be added
implicitly.
"-print0"
Like -print, but terminates with instead of
.
"-exec OPTIONS ;"
exec() the arguments in OPTIONS in a subprocess; any occurrence of {} in OPTIONS will first be substituted with the path of the current
file. Note that the command "rm" has been special-cased to use perl's unlink() function instead (as an optimization). The ";" must be
passed as a distinct argument, so it may need to be surrounded by whitespace and/or quoted from interpretation by the shell using a
backslash (just as with using find(1)).
"-ok OPTIONS ;"
Like -exec, but first prompts user; if user's response does not begin with a y, skip the exec. The ";" must be passed as a distinct
argument, so it may need to be surrounded by whitespace and/or quoted from interpretation by the shell using a backslash (just as with
using find(1)).
"-eval EXPR"
Has the perl script eval() the EXPR.
"-ls"
Simulates "-exec ls -dils {} ;"
"-tar FILE"
Adds current output to tar-format FILE.
"-cpio FILE"
Adds current output to old-style cpio-format FILE.
"-ncpio FILE"
Adds current output to "new"-style cpio-format FILE.
Predicates which take a numeric argument N can come in three forms:
* N is prefixed with a +: match values greater than N
* N is prefixed with a -: match values less than N
* N is not prefixed with either + or -: match only values equal to N
SEE ALSO
find, File::Find.
perl v5.18.2 2018-08-17 FIND2PERL(1)