How to monitor a unix folder?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to monitor a unix folder?
# 1  
Old 01-03-2008
Question How to monitor a unix folder?

SmilieHi All,
I have a folder on Sun Solaris 5.8 SPAC and I'm trying to build a monitoring shell or perl script that sends an email to a user whenever a file was put into this folder.
issue:
if I create a new file in the folder using like 'touch newfile', then the newfile has a current unix system timestamp on it, but if I drag a file from a windows xp to this unix folder, the timestamp of the file wouldn't change, it still keeps the created time when I created it on win xp, so it's impossible to monitor the folder by checking all files timestamp.

How can I work around this issue?
any ideas are appreciated.

Thanks,
Bizheng
# 2  
Old 01-03-2008
Have you tried looking at ctime instead of mtime?
# 3  
Old 01-03-2008
If this is linux: man fcntl and look at the F_NOTIFY interface.
# 4  
Old 01-03-2008
Quote:
Originally Posted by ramen_noodle
If this is linux: man fcntl and look at the F_NOTIFY interface.
The original post stated that this was Solaris 8.
# 5  
Old 01-03-2008
it works!

it seems to use ctime can fix this problem, no matter the file was created by unix user or was dragged from windows xp, ctime always shows the time when it was created in UNIX, but 'ls -l' only shows modification time, if the file's from windows then ctime , mtime are different.

Thanks all for your replies, really appreciated!
# 6  
Old 01-03-2008
Hi.
Quote:
Originally Posted by bizheng
it seems to use ctime can fix this problem, no matter the file was created by unix user or was dragged from windows xp, ctime always shows the time when it was created in UNIX ...
Use caution in interpreting the "c" in ctime:
Quote:
stat() is a Unix system call that returns useful data about an inode. The semantics of stat() vary between operating systems. With Unix command ls, one can gather information about

* mtime: time of last modification (ls -l),
* ctime: time of last status change (ls -lc) and
* atime: time of last access (ls -lu).

Note, that ctime is not the time of file creation. Overwriting a file changes mtime, ctime as well as atime. A change in file permissions or file ownership changes ctime and atime. Reading a file changes atime.

-- stat (Unix) - Wikipedia, the free encyclopedia
Best wishes ... cheers, drl
# 7  
Old 01-03-2008
Hi.

I think I'd look at the mtime of the directory in which the files are being placed.

I'm somewhat surprised that Sun doesn't have anything to address this kind of situation. I looked briefly through Sun Microsystems - BigAdmin System Administration Portal and saw nothing on point ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to monitor kill commands in UNIX.?

Hi All, I want to know how can we monitor the kill commands that we execute in Unix. Much appreciate your help. Thanks. (5 Replies)
Discussion started by: kmadhubabu82
5 Replies

2. Shell Programming and Scripting

Monitor and restart UNIX process

Hi all, Tearing my hair out..! I have a requirement to monitor and restart a unix process via a simple watchdog script. I have the following 3 scripts that dont work for me.. script 1 (only produces 1 output if process is up or not)... (4 Replies)
Discussion started by: jonnyd
4 Replies

3. Shell Programming and Scripting

Shell Script to monitor folder and upload found files via FTP

Hi everyone! I'm in a need of a shell script that search for all files in a folder, move all those files to a temp folder, and upload those files via FTP. When the file transfer via FTP completes successfully, the file is moved to a completed folder. In case any of those files fails, the file... (4 Replies)
Discussion started by: pulsorock
4 Replies

4. Shell Programming and Scripting

how to monitor a folder using script

hi, i want to monitor a particuler folder and have to report is there any new file added to the dir or not? can anyone tell me how to monitor the folder using script. the script has to run in the background continiously. Is there any way to do it? (2 Replies)
Discussion started by: vij_krr
2 Replies

5. Shell Programming and Scripting

how to create folder and sub-folder in UNIX ?

Hi all, I have the following code to check the whether the folder is exist in my system. if ; then echo 'folder exist'; else echo 'folder not exist'; mkdir /home/batch/testing ; fi When I remove the "testing" folder from "/home/batch" directory, the code is working fine. But when I... (2 Replies)
Discussion started by: suigion
2 Replies

6. UNIX for Dummies Questions & Answers

How to monitor Unix server CPU status?

I like to know how to monitor the UNIX CPU/memory status over time. I need to data to do some graphical representation of the server load. I sort of need to keep track of the vmstat but i dont know how. I hope someone would kindly help me out. thanks. (1 Reply)
Discussion started by: shingpui
1 Replies

7. UNIX for Advanced & Expert Users

How do I monitor packets by OS id on a UNIX box?

We think we may have an IO problem. We have 2 identical Oracle servers with the exact same objects in each database. In one database, the first time a query is executed and the data is moved to SGA from disk the query takes about 40 seconds. However, in the other data base, when the query is... (3 Replies)
Discussion started by: shawn_holman
3 Replies

8. Windows & DOS: Issues & Discussions

How can I upload a zip folder on a unix path from my windows folder?

Hello, I am an amature at UNIX commands and functionality. Please could you all assist me by replying to my below mentioned querry : How can I upload a zip folder on a unix path from my windows folder? Thanks guys Cheers (2 Replies)
Discussion started by: ajit.yadav83
2 Replies

9. Shell Programming and Scripting

File/Folder monitor

Dear All I had made 2 folder name folder a and b. In folder a i am receiving some file from another server. And this file are moved to folder b using one script twice a hour. Is there any commnad or utility in unix so that i cam monitor folder a file ..mena how many file i had received in... (1 Reply)
Discussion started by: jaydeep_sadaria
1 Replies

10. Shell Programming and Scripting

Shell script to monitor tmp folder for uploads

Hello, We have been having some issues with our users overwriting files, and then not having a backup. What I would love to do, is create a shell script to monitor /tmp, for uploads, and make a copy of the file they are trying to upload before the upload finishes. Is this possible at all? (6 Replies)
Discussion started by: mrfr0g
6 Replies
Login or Register to Ask a Question