Folder Watch


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Folder Watch
# 1  
Old 02-15-2009
Folder Watch

Hi there,

I was wondering if there was a way in UNIX that I could set up a running script that monitors a certain folder (and all the folders and files contained within it) so that if any file changes then it will be the change logged within a log file. I dont know if this is possible in Unix but who knows...

Cheers

Colin
# 2  
Old 02-15-2009
Code:
ls -al foo > contents

then
Code:
#!/bin/sh
DIR=foo
STATIC=contents
ls -al $DIR > contents.tmp

diff -q contents.tmp $STATIC  
if [ ! $? -eq 0 ]
then
	cp contents.tmp $STATIC
	echo "Directory Changed" | mail -s "Directory Changed $DIR" youremail@yourhost.com
fi

exit 0

You could set this up to run in cron.
# 3  
Old 02-15-2009
It's cool. Smilie
# 4  
Old 02-15-2009
Thanks for the reply. That looks exactly what I needed.

Rgds

colin
# 5  
Old 02-15-2009
Quote:
Originally Posted by glen.barber
Code:
diff -q contents.tmp $STATIC  
if [ ! $? -eq 0 ]

Should be:
Code:
diff -q contents.tmp $STATIC  
if [ $? -ne 0 ]

# 6  
Old 02-15-2009
Well, as far as I am concerned, "not equal to" means "not equal to" no matter how you word it.
# 7  
Old 02-15-2009
Quote:
Originally Posted by glen.barber
Well, as far as I am concerned,
I see Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

2. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

3. Shell Programming and Scripting

Using the watch command

so i have a very long script which i have to run. when i run this script, i want to monitor the the openssl commands it runs. the way ive attempted to do this is: watch -t -n 1 "(date '+TIME:%H:%M:%S' ; ps aux | egrep openssl | egrep -v grep)" 2>&1 | tee -a logfile the above command is... (2 Replies)
Discussion started by: SkySmart
2 Replies

4. Shell Programming and Scripting

Can I use a shell script for deleting chunks from a watch folder?

Hello I have a unique problem of needing to delete large files slowly off of an XSan. I was wondering if there is a script I could use to delete 100gb chunks of files and folders that get placed in to a watch folder, slowly so as not to disrupt the other users. I would like to use Automator in... (0 Replies)
Discussion started by: ajsoto
0 Replies

5. UNIX for Dummies Questions & Answers

watch command

Hi, Please help me out! In the man pages they dont talk about any options that can be used to terminate a running 'watch' command. Do you know a way of terminating the command using an option? Thanks (1 Reply)
Discussion started by: foxtron
1 Replies

6. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies

7. News, Links, Events and Announcements

Watch The Time !!!

watch your clock! Unix-time @ 1:58:31 UTC (2:58:31 MEZ) == 1111111111 ;-) no chance to see such a combination again... 2222222222 will be beyond our time..... http://en.wikipedia.org/wiki/Unix_time greetings PRESSY (0 Replies)
Discussion started by: pressy
0 Replies
Login or Register to Ask a Question