i have the delete the log files which are present in the specific path .i have the rules as below.
1)In Path1 i need to delete all the files which are present
2)in Path2 i need to keep 1 month of data and delete the rest of the data
3)in Path3 i need to keep 2 weeks of data and delete all the files.
4)in Path4 i need to keep 1 year of data and delete all the files which are more than one year.
5)in path5 i need to keep last 2 backups which are kept .
i need a generic code .i have tried using the below code but failed to execute can any one of you please help me in completing my code.
My idea is based on the letter m,y,d it should calculate and delete the files .
Last edited by Don Cragun; 10-14-2015 at 04:27 PM..
Reason: Add CODE tags.
Note that defining a shell function doesn't execute that function. Something in your shell script needs to actually invoke your function (passing it at least two operands).
This User Gave Thanks to Don Cragun For This Post:
Thank You for the reply,Can you help me with the commands for the last 2 backups which are kept .
The +14 is the number of days to keep, /logdir/* is the path to the files that need to be purged, -name *.log is to make sure that you only delete log files, -type f specifies that this only applies to files and not directories, finally xargs rm -rvf does the remove operation.
we need to have periodic clean up implemented in our sap directory \\sapds\PR1\int\scm\snp\outbound\snapshot. which needs unix script for Deleting files older than 14 days automatically in sap system unix os. (1 Reply)
#!/bin/bash
#
name=$1
type=$2
number=1
for file in ./**
do
if
then
filenumber=00$number
elif
then
filenumber=0$number
fi
tempname="$name""$filenumber"."$type"
if (4 Replies)
Hi
Can someone assist in writing a script.
I have a filesystem named /sybase in my aix lpar.
When this filesystem becomes 94% full all the files and directories under /sybase/logs should be deleted immediately. :confused: (7 Replies)
Hi.
I need help with a little script that will be used to move some files to their parent directory, delete the directory, rename one file in the parent directory and delete another, then continue to the next.
Here's an example:
/var/media/Music/Genesis/1970 album - Trespass (2008 Box -... (4 Replies)
Hi All,
I have written the below script that searches for the pattern in a file and delete them if present. please can some one have a look and suggest the changes in the script.
#!bin/sh
# The pattern that user want to add to the files
echo "Enter the pattern of the redirect"
read... (4 Replies)
Hi,
I am using the command find /apps/qualdb/gpcn/scripts/cab_outbound/archive -name 'z*' -mtime +28 -exec rm {} \;
in unix command prompt
for deleting the files in my unix system under the specfied folder. It was succesfull.
But when i running this command inside a shell script name... (2 Replies)
Hi All,
I need a script which compares the sysdate and the file date(Last updated time stamp) and if the time difference is greater than 10 mins i need to delete that file. Can anyone help me pls??????
Ashok. (5 Replies)
I have written a script that deletes files:
Requirement: i need to delete the files and to know how many files are deleted i.e the count of files and even i need to display when the started time of deletion and the ending time of deletion. I need to display these two times.
script:
... (2 Replies)
ok i am setting up a script to run daily using crontab. This script will search the root filesystem and delete any and all core files. I have set up this script
The only problem i get with this script is it searches for directories and attempts to delete them. Since i have probably... (7 Replies)
i have the following problem:
use shell script:
Two directories have to be searched for files havin the same name.
then delete these files from one of these directories.
the directory names have to be accepted as command line arguments.
what i have done till now is:
1. run a loop... (1 Reply)