30 days oldfiles: Urgent


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting 30 days oldfiles: Urgent
# 1  
Old 03-02-2009
MySQL 30 days oldfiles: Urgent

I wanted to find 30 days old file list from my datafile location named" u01/u02...etc".

Last edited by gorugand; 03-13-2009 at 08:33 AM..
# 2  
Old 03-02-2009
Can you be more specific in describing the problem as it is difficult to figure out what you are trying to do by reading your code. Show us typical input.
# 3  
Old 03-02-2009
Quote:
Originally Posted by ripat
Can you be more specific in describing the problem as it is difficult to figure out what you are trying to do by reading your code. Show us typical input.

I wanted to find all old file lists on my linux server.
In the above script i am not passing any input parameters.

When i ran this script , no output is displayed but i know the fact there are files whcih are older than 30 days.

I would like to fix for loop issue which i suspect as error.
# 4  
Old 03-02-2009
Here is a start, first figure out when was 30 days ago..

#!/usr/bin/ksh
DAYS_AGO=30
DAY=`date +%d`
LMONTH=`date +%b`
MONTH=`date +%m`
YEAR=`date +%Y`
DAY_1=`expr "$DAY" - $DAYS_AGO`

if [ $DAYS_AGO -ge $DAY ];then
MONTH=`expr "$MONTH" - 1`
case "$MONTH" in
0) MONTH=12;YEAR=`expr "$YEAR" - 1` ;;
esac
DAY_2=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1`
DAY_Diff=`expr $DAYS_AGO - $DAY`
REAL_DATE=`expr $DAY_2 - $DAY_Diff`
if [ $REAL_DATE = 0 ] ; then
MONTH=`expr $MONTH - 1`
DAY=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1`
fi
fi

MONTH_LEN=`echo $MONTH|wc -c`
echo $MONTH_LEN
if [ $MONTH_LEN -eq 2 ]; then
MONTH="0$MONTH"
fi
DAY_LEN=`echo $DAY|wc -c`
echo $DAY_LEN
if [ $DAY_LEN -eq 2 ]; then
DAY="0$DAY"
fi
case $MONTH in # set month name
01) LMONTH="Jan";;
02) LMONTH="Feb";;
03) LMONTH="Mar";;
04) LMONTH="Apr";;
05) LMONTH="May";;
06) LMONTH="Jun";;
07) LMONTH="Jul";;
08) LMONTH="Aug";;
09) LMONTH="Sep";;
10) LMONTH="Oct";;
11) LMONTH="Nov";;
12) LMONTH="Dec";;
esac
echo "$YEAR/$MONTH/$DAY $LMONTH"
# 5  
Old 03-02-2009
I have a directory with about 20 sub directories in it that has a thousands of files in them all together, I need a script to find what is the oldest file and show date and time created in which ever one of these sub directories.
# 6  
Old 03-02-2009
Will anybody able to help me ?
# 7  
Old 03-02-2009
hi msullivan, would you mind to share how to make past 3 days ?
I was trying to make change of DAY_AGO=3, it doesn't work at all.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to find a file that's modified more than 2 days ago but less than 5 days ago?

How to find a file that's modified more than 2 days ago but was modified less than 5 days ago by use of any Linux utility ? (4 Replies)
Discussion started by: abdulbadii
4 Replies

2. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

3. Shell Programming and Scripting

Working out days of the week and processing file in 3 working days

Hi guys i need advice on the approach to this one...... I have a file say called Thisfile.20130524.txt i need to work out from the date 20130524 what day of the week that was and then process the file in 3 working days. (so not counting saturday or sunday....(will not worry about bank... (2 Replies)
Discussion started by: twinion
2 Replies

4. Shell Programming and Scripting

Cron job running for some days and is not running for some days

Hi.. i have written a shell script and made this script to run on every day night 11: 55 pm using a cron job. This cron job running for some days and is not running for some day. but i need this script to run every day night. Please help me. Here is the cron tab entries, 55 23 * * *... (1 Reply)
Discussion started by: vidhyaS
1 Replies

5. Shell Programming and Scripting

before x days

hello, I needed to put value of date - 20 days in certain variable like this: before20d=`TZ=MET+480 date +%Y%m%d` echo $before20d value just perfect ...what I need and if I execute "date": Wed Nov 10 11:58:43 MET 2010 on the other solaris platform if I execute this I get... (4 Replies)
Discussion started by: abdulaziz
4 Replies

6. Shell Programming and Scripting

date for two days or 3 days ago

i need a script that can tell me the date 2 days ago or 3 days ago. please help (7 Replies)
Discussion started by: tomjones
7 Replies

7. Shell Programming and Scripting

ls latest 4 days or specify days of files in the directory

Hi, I would like to list latest 2 days, 3 days or 4 days,etc of files in the directory... how? is it using ls? (3 Replies)
Discussion started by: happyv
3 Replies

8. UNIX for Advanced & Expert Users

URGENT,URGENT- Need help tape drive installation

Hi, I am trying to attach tape drive to sun V890 running Solaris 9 on it. I have installed HBA(qlogic) in slot 1 of 0-8 slots and booted the system. I do not see HBAin prtdiag output. The tape drive is not attached to HBA. The tape drive I am going to attach is Sony AIT3. 1.How can I make... (3 Replies)
Discussion started by: sriny
3 Replies
Login or Register to Ask a Question