List files which access before 2 hours in solaris


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting List files which access before 2 hours in solaris
# 1  
Old 12-12-2011
List files which access before 2 hours in solaris

Hi Friends,

I want to the list the files in the folder which was access before 2 hours in Solaris.


Thanks in advance......
# 2  
Old 12-12-2011
Try this...
Code:
find /from/where/to/search -amin 120

--ahamed
# 3  
Old 12-12-2011
amin option is not working in Solaris OS.
# 4  
Old 12-12-2011
The hard way.

bash code:
  1. #! /bin/bash
  2.  
  3. CURR_DATE=`date +%Y%m%d`
  4. TIME_2hrs_ago=`date --date="-2 hours" +%H%M`
  5.  
  6. for x in `ls`
  7. do
  8.     FILE_ACC_DATE=`stat $x | sed -n 5p | awk '{print $2}' | tr -d '-'`
  9.     FILE_ACC_TIME=`stat $x | sed -n 5p | awk '{print $3}' | tr -d ':' | cut -c1-4`
  10.     if [ $FILE_ACC_DATE -eq $CURR_DATE -a $FILE_ACC_TIME -gt $TIME_2hrs_ago ]
  11.     then
  12.         continue
  13.     else
  14.         echo $x
  15.     fi
  16. done

Last edited by balajesuri; 12-12-2011 at 07:46 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List of Running Jobs In Last 4 Hours

Hi Experts, Please help me in this. I am trying this code on AIX 5.3. I need list of jobs that executed in last 4 hours. I have a schedule on this script - cron executes it and sends mail to me for every 2 hours. I have a Job time and have around 100 jobs those execute daily. What all i need... (2 Replies)
Discussion started by: rajubollas
2 Replies

2. Homework & Coursework Questions

list of files modified 10 hours ago using grep

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Here is the question: Make a list of files in your home directory that were changed less that 10 hours ago,... (3 Replies)
Discussion started by: fight4love
3 Replies

3. Shell Programming and Scripting

Command to clear logs for every 6 hours in solaris

Hi Folks, I need to remove log files for six hours on Solaris. before i used to do for every 24 hours below is the code for 1 day older log files, now i tried using -mmin +360 but it says command not found. Can someone please help me out!!! part of the code: LOG_FILE=`find /home/Logdir... (1 Reply)
Discussion started by: Sendhil.Kumaran
1 Replies

4. Solaris

Solaris 10 patching - 14 hours!!!

Hi, we have a problem recently with Sun Fire T200 server, when installing 10_SPARC_EIS-Jul09 patchbundle resulted for 14 hours of outage! Steps, that was done by me is pretty straightforward: reboot -- -s ./installcluster --s10cluster Then I made 1 reboot after kernel patch was installed... (10 Replies)
Discussion started by: masloff
10 Replies

5. Shell Programming and Scripting

Splitting a list @list by space delimiter so i can access it by using $list[0 ..1..2]

EDIT : This is for perl @data2 = grep(/$data/, @list_now); This gives me @data2 as Printing data2 11 testzone1 running /zones/testzone1 ***-*****-****-*****-***** native shared But I really cant access data2 by its individual elements. $data2 is the entire list, while $data,2,3...... (1 Reply)
Discussion started by: shriyer
1 Replies

6. Shell Programming and Scripting

how to list files between last 6 hours to 3 hours

Hi Frens, I want to list some files from a directory, which contains "DONE" in their name, i am receiving files every minute. In this i want to list all the files which are newer than 6 hours but older than 3 hours, of current time i dont want my list to contain the latest files which are ... (4 Replies)
Discussion started by: Prat007
4 Replies

7. UNIX for Dummies Questions & Answers

How can I get the list of files if I have root access?

Hi, I'm very new and dumb in linux. What I do is: I use putty to connect to the linux server. I use auth.komtels.ru as a connection line root and oP04Koh0 as a password port 6262, and SSH protocol now I need to get the list of the files, how could I do it? (1 Reply)
Discussion started by: linuxbeginner
1 Replies

8. Shell Programming and Scripting

list the file created before 24 hours using ls command

I want to list the files created before past 24 hours using ls command. please help me on this (7 Replies)
Discussion started by: jayaramanit
7 Replies

9. HP-UX

HPUX list files with access time more than 5 min

Hi, does anyone know how to find files who have the last access time bigger than 5 min ago, in linux i use: find ./ -amin +5 -type f -maxdepth 1 -name "*.*" but in hp-ux the find command doesn't have the -amin option.... (2 Replies)
Discussion started by: mvrk
2 Replies
Login or Register to Ask a Question