Solaris files created within directory in last 15min.


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Solaris files created within directory in last 15min.
# 1  
Old 09-19-2012
Data Solaris files created within directory in last 15min.

I have a directory on a Solaris box that has 58 files written to it every 15min. They have a non standard date as part of the file name but always have another name with it. I need to check that directory for files created within the last 15min and then port the results to a log file. There are thousands of files but should only be and up to 58 within the last 15min. Wish there was ls for it but I can't find any. Anyone got a script or knows of a command?

Thanks,
Jaime
# 2  
Old 09-19-2012
There is a serious lack of detail in this post.
What version of Solaris?
What Shell do you use?
What are the filenames? Any special name for the LAST file to be transferred in a batch of files?
How long does it take to create the "up to 58 files"? Let's hope that it is nowhere near 15 mins?
How often do you need to check?
Why are you doing this?

As posted, this task is impossible to program. However you approach it there is a good chance of hitting a point part-way through a batch of file transfers.

Suggest you consider changing the process such that subsequent processing is feasible. Creating a zero-length "started" file at the start of each batch of files and a zero-length "finished" file at the end of each batch is a good method for delimiting batches with timestamped files.
As for commands, let's see what your environment is and how often you need to check. We shall assume throughout that you are the root user and have full permissions to create cron jobs.
# 3  
Old 09-19-2012
Unfortunately the amin, mmin and cmin options are not supported in the Solaris version of find.

With some tweeking, this workaround using Perl might work for you: Find files modified in the last hour
# 4  
Old 09-20-2012
find will work
Code:
# assume    15 minutes ago
a=$( date +%H%M )
a=$(( $a - 15 ))
touch -t $a /tmp/dummy1
find /path -newer /tmp/dummy1 -exec ls -l  {} \;

you can compute that value but it will not work if you run this just after midnight.
This User Gave Thanks to jim mcnamara For This Post:
# 5  
Old 09-20-2012
I get a time error?

Code:
bash-3.00$ more testing.sh 
# assume    15 minutes ago
a=$( date +%H%M )
a=$(( $a - 15 ))
touch -t $a /tmp/Spirent_TCL/testing.log
find /spirent/metro/escout/exportData/data -newer /tmp/Spirent_TCL/testing.log -exec ls -l  {} \;
bash-3.00$ 
bash-3.00$ 
bash-3.00$ ./testing.sh 
touch: bad time specification
bash-3.00$ date
Thu Sep 20 16:37:12 GMT 2012
bash-3.00$ date +%H%M
1637
bash-3.00$ uname -a
SunOS tclsnq01 5.10 Generic_144488-17 sun4v sparc sun4v
bash-3.00$

Moderator's Comments:
Mod Comment Please view this code tag video for how to use code tags when posting code and data.
# 6  
Old 09-20-2012
You can't use just hours and minutes as argument to the -t option. Usage is:
Code:
-t [[CC]YY]MMDDhhmm[.SS]

This User Gave Thanks to hergp For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

2. Shell Programming and Scripting

Script needed to delete to the list of files in a directory based on last created & delete them

Hi My directory structure is as below. dir1, dir2, dir3 I have the list of files to be deleted in the below path as below. /staging/retain_for_2years/Cleanup/log $ ls -lrt total 0 drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2 drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies

3. Shell Programming and Scripting

How to find the files created within one hour in Solaris?

Hi Gurus, I want to find the file created within one hour in solaris. I have tried below command, but it is no lucky. $find . -mtime -1/24, -name "abc*" above command give me the file name which created two hours ago find . -cmin -60, -name "abc*" above command I got error as... (4 Replies)
Discussion started by: ken6503
4 Replies

4. Shell Programming and Scripting

Solaris: New files in a directory for longer than 1h

Hi guys, I have an interesting problem. I have looked on the forums for simular solutions but i need a differnt approach. On an evening i have files that are created and sit in a directory, then someone will send these files on. Sometimes they forget..... I am trying to create something... (7 Replies)
Discussion started by: twinion
7 Replies

5. Shell Programming and Scripting

How to find files created today in a particular directory?

Dear All, I want a Hp Ux command to find out the files created today in a particular directory or mountpoint. Kindly help. Thanks Bhaskar (10 Replies)
Discussion started by: sudiptabhaskar
10 Replies

6. UNIX for Dummies Questions & Answers

Shell script which will sort all the files in a directory with the timestamp they were created

Team, Pls help writing a shell script which will sort all the files in a directory with the timestamp they were created. (like ls -lrt) (6 Replies)
Discussion started by: asappidi
6 Replies

7. Shell Programming and Scripting

Need the date now + 15min

Hello all, How can I get a timestamp with 15 min more than current time ? I want to get it like YYYYMMDD-HHMMSS Thank you for your answers :b: Regards (3 Replies)
Discussion started by: Goldorakk
3 Replies

8. UNIX for Dummies Questions & Answers

To list all the files created today with directory path

Hi, Can any one tell the command to list all the files that are created as of today from all the directories? The Command "ls -ltR" is listing all the files. But I want the list of files that has been created as of today along with the directory path:) Thank you in advance.:) Regards,... (4 Replies)
Discussion started by: meetusha.b
4 Replies

9. UNIX for Dummies Questions & Answers

Find all files created by a specified user in a directory and its subdirectories

Is there a command or shell script which can be used for Finding all files created by a specified userid in a directory and its subdirectories. Say, I want to find all such files in directory /abc as well as in all the subdirectories such as /abc/xyz or /abc/xyz/pqr aqnd so on which was created... (5 Replies)
Discussion started by: abhilashnair
5 Replies

10. UNIX for Dummies Questions & Answers

new directory - how to force files created in it to inherit grp,own and permissions

Hi, I'm new to unix -solaris. I've just upgraded a third party software product and am testing it to see if new files created in a test database directory were being created properly and they aren't. They're owned by the user that created the file, instead of poppa and the group of their files... (2 Replies)
Discussion started by: avisb
2 Replies
Login or Register to Ask a Question

Featured Tech Videos