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

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Solaris: New files in a directory for longer than 1h
# 1  
Old 03-21-2014
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 that will monitor the directory for new files but the files have been there for more than an hour and alerting. I have the alerting in place, but i can't get my brain to think of a good solution.

As it is a solaris system that i can't install any packages on.... i am taking an approach of:

creating a date stamp of an hour ago
touching a file with that date stamp then doing a find and showing all files created after my touched file
DAT=`date '+%Y%m%d'$A'%M'`
echo "hi " > the.tmp
touch -t $DAT the.tmp
find /directorytofiles -type f -newer the.tmp -print -exec ls -lt {} \; | pg

now this shows all files created after the the touched files datestamp(1hour ago) but also shows files created 1 min ago (i dont want it to alert these files as they just turned up) I could run via cron every 15 mins or so.

Am i complicating things? is there a better approach? Any suggestions would be great and what would be the best idea to get it to just show the files that have turned up and not sent after an hour?Smilie

Last edited by Franklin52; 03-21-2014 at 10:29 AM.. Reason: Please use code tags
# 2  
Old 03-21-2014
Hi guy,
I'm confused, I remeber that even solaris 'find' has some option just like "cmin amin mmin".
find /path -type f -mmin+60

You could find the files that have turned up and not sent after an hour easily.
# 3  
Old 03-21-2014
Originally Posted by Lucas_0418
Hi guy,
I'm confused, I remeber that even solaris 'find' has some option just like "cmin amin mmin".
find /path -type f -mmin+60

You could find the files that have turned up and not sent after an hour easily.
alas not on this one, would make life soooo much easier, that is why i am forced to take a weird approach

i have -mtime -ctime -atime, those are no use at all as i think they are via days
# 4  
Old 03-21-2014
I'm sorry to hear that, the 'find' in your OS must frustrated you..

Are you able to touch some file in the directory that you are monitoring ?
If so, you could run your script via cron every hour.
every time you run this script, you touch a mark file in that directory,
when you run this script every the next time, use
ls -t|sed '/your_mark_file_name/,$d'

This is the best method that I get now~.
This User Gave Thanks to Lucas_0418 For This Post:
# 5  
Old 03-21-2014
I think i may need to do something like this, i was hoping not to put specific file names as i have 4 systems and they all have diff file names plus i would need to modify for new files. If i took this appraoch i may as well automate and send the files too. This Script could get a whole lot bigger lol
# 6  
Old 03-21-2014
This thread is confusing. There is a simple way to find files of a given "age".
The basic idea is:
touch -t [min allowable time in past] dummy1   # youngest filetime to find
touch -t [ max allowable time int the past ] dummy2  # oldest filetime to find
find . -type f \( ! -newer dummy1 -a -newer dummy2 \)

Bracket around some time requirement. You can find all files 1 hour and older, say up to 5 days. This seems to be what you want.

Except the way the problem is stated the answer is not clear. At least to me.
# 7  
Old 03-21-2014
Hah, also you could remove the previous mark file and touch a new one with the same name in the end of your script, you just need to choose a specific file name for every system~
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Directory containing files,Print names of the files in the directory that are exactly same content.

Given a directory containing say a few thousand files, please output a list of all the names of the files in the directory that are exactly the same, i.e. have the same contents. func(a_directory_name) output -> {“matches”: , ... ]} e.g. func(“/home/my/files”) where the directory... (7 Replies)
Discussion started by: anuragpgtgerman
7 Replies

2. 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 some_name_2016-01-17-22-40-30_some some_name_2016-01-17-22-48-50_some and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

3. Solaris

Copy via samba on vmware workstation with Solaris taking much longer than usual

i have a vmware workstation with solaris 10 installed on this. i copying 2 gb data via samba from windows to this vmware workstation. copy speed is 24 kb/sec. how i can speed up this copy process ? (7 Replies)
Discussion started by: rehantayyab82
7 Replies

4. UNIX for Advanced & Expert Users

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... (5 Replies)
Discussion started by: jlaigo2
5 Replies

5. Shell Programming and Scripting

Grepping file names, comparing them to a directory of files, and moving them into a new directory

got it figured out :) (1 Reply)
Discussion started by: sHockz
1 Replies

6. Shell Programming and Scripting

Need to Zip files three years old or longer but leave folder structure intact

Hi all, Hello everyone, my first post here :). I tried to search the forum but I didn't find exactly what I was looking for... I need to zip/tar files across entire filesystem which are more 3+ years old but leave folder structure intact. If the script locates tar/zip files they are more... (1 Reply)
Discussion started by: sashruby
1 Replies

7. Solaris

Graphical program no longer works after Solaris 10 upgrade

This is a fairly complex issue. I do not have a lot of knowledge on X11. But here are the things. I am running a program called Synergy off a Solaris server. The server sits in a remote network and can be accessed via NAT. Using Putty, I will enable X11 forwarding and launch Synergy via Putty.... (0 Replies)
Discussion started by: Leion
0 Replies

8. Solaris

solaris 10 mysql no longer able to restart

Came in tonight, and some people started getting this error message note: users were getting this error in IE6 and in firefox, pages seemed to process fine in Chrome. :confused: anyway... So I decided to restart the MySQL service, now it will not restart. First tried: root@bender:/>... (2 Replies)
Discussion started by: ippy98
2 Replies

9. UNIX for Advanced & Expert Users

logrotate isn't rotating files any longer

I have been using logrotate for quite awhile now. Most logs are rotated daily, using /etc/cron.daily. I noticed that the logs in question have not been rotated since April 6, but daily up to that point. I have logrotate in /etc/cron.daily. The basic command is: /usr/sbin/logrotate... (1 Reply)
Discussion started by: manouche
1 Replies

10. UNIX for Advanced & Expert Users

scripts no longer running (solaris 8)

hello: I am a somewhat experienced unix user, but brand new to this forum. I am encountering a strange new problem. I have a shell script called foo.ksh it has been running for years (literally) on my Sun (Solaris 8) machine. Recently we put a version of samba on this machine to... (3 Replies)
Discussion started by: smcadoo
3 Replies
Login or Register to Ask a Question