11-12-2007
How to watch for file creation/deletion?
How do I write a C program that will watch a directory for file creation/deletion? Maybe it would receive a signal when someone creates a file?
thanks,
Siegfried
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi there guys. I'm quite new in using unix and just recently experienced missing file problem. Someone accidentally or likely intentionally deleted one specific folders that contains important file. Now my question is, can any other user aside from root can do such action? Please help. ... (2 Replies)
Discussion started by: rhomel101
2 Replies
2. UNIX for Dummies Questions & Answers
OS: Solaris 8
I deleted a large file (around 13 Gigs) from my system.
But the output of df -k remains the same. The
capacity % is constant. However one strange thing
is happening- My available space is decreasing, my used
space in increasing (The opposite should happen).
This is happening... (2 Replies)
Discussion started by: run_time_error
2 Replies
3. UNIX for Dummies Questions & Answers
I am using unix via telnet ssh and i have a problem
I was testing the server.
I made a directory.
Transfered a file from an ftp to it.
Opened the file with the vi text editor
--This where my problem came.....
I tried deleting the file using rm somefile.htm
when is typed ls i noticed that... (2 Replies)
Discussion started by: shdwsclan
2 Replies
4. Shell Programming and Scripting
I got help in another forum but now I need further help so I figured I'd ask here. I had to write a script to delete certain filenames of certain size. I got this far..
find . -size 110c -name "*testing*" -print | xargs -n 1 rm -i
It finds the correct files, but the prompts to delete are all... (2 Replies)
Discussion started by: NycUnxer
2 Replies
5. UNIX for Dummies Questions & Answers
I want to poll a particular file on a Windows shared drive using shell script and copy it to a Unix directory if present.
Step wise execution:
1) Poll/watch for a file in the following location on Windows share:
(SRC_DIR=\\mum\dharmesh\research\ST_DXR_20080821 to DXR.xls)
2) If present,... (1 Reply)
Discussion started by: dharam_v
1 Replies
6. UNIX for Dummies Questions & Answers
I need to write a simple shell script to watch a file in a directory and copy immedietly any files in that directory to another oldfiles directory once and later in the evening delete the file from the original directory.
File A arrives in dir1 at 8.00AM
Watch the file in dir1 and copy the file... (2 Replies)
Discussion started by: cravie
2 Replies
7. Shell Programming and Scripting
I looked into the sticky bit, but I think, if possible, that I would prefer to have the file recreate itself after deletion. The file is several directories deep, and from time to time the top level directory will be trashed. I need the file to recreate after this. Is it possible to perhaps... (13 Replies)
Discussion started by: glev2005
13 Replies
8. Shell Programming and Scripting
Hi Everyone,
There are certain files under a folder 'ABC' and the entries for these files are there in another file(fname) under a different folder 'XYZ'. I want to compare the folder contents(ABC) with
the file(fname) contents and delete the mismatching / non-existing ones from the file,... (4 Replies)
Discussion started by: swasid
4 Replies
9. Shell Programming and Scripting
Can someone help me with a shell script that will send an email to a set of email ids when a user id is created or deleted on AIX system.
Also, if the script can let the admin know when a particular user id's password will expire. (2 Replies)
Discussion started by: ggayathri
2 Replies
10. Emergency UNIX and Linux Support
Can someone help me with a shell script that will send an email to a set of email ids when a user id is created or deleted on AIX system.
Also, if the script can let the admin know when a particular user id's password will expire. (4 Replies)
Discussion started by: ggayathri
4 Replies
WATCH(1) Linux User's Manual WATCH(1)
NAME
watch - execute a program periodically, showing output fullscreen
SYNOPSIS
watch [-dhv] [-n <seconds>] [--differences[=cumulative]] [--help] [--interval=<seconds>] [--version] <command>
DESCRIPTION
watch runs command repeatedly, displaying its output (the first screenfull). This allows you to watch the program output change over time.
By default, the program is run every 2 seconds; use -n or --interval to specify a different interval.
The -d or --differences flag will highlight the differences between successive updates. The --cumulative option makes highlighting
"sticky", presenting a running display of all positions that have ever changed.
watch will run until interrupted.
NOTE
Note that command is given to "sh -c" which means that you may need to use extra quoting to get the desired effect.
Note that POSIX option processing is used (i.e., option processing stops at the first non-option argument). This means that flags after
command don't get interpreted by watch itself.
EXAMPLES
To watch for mail, you might do
watch -n 60 from
To watch the contents of a directory change, you could use
watch -d ls -l
If you're only interested in files owned by user joe, you might use
watch -d 'ls -l | fgrep joe'
To see the effects of quoting, try these out
watch echo $$
watch echo '$$'
watch echo "'"'$$'"'"
You can watch for your administrator to install the latest kernel with
watch uname -r
(Just kidding.)
BUGS
Upon terminal resize, the screen will not be correctly repainted until the next scheduled update. All --differences highlighting is lost
on that update as well.
Non-printing characters are stripped from program output. Use "cat -v" as part of the command pipeline if you want to see them.
AUTHORS
The original watch was written by Tony Rems <rembo@unisoft.com> in 1991, with mods and corrections by Francois Pinard. It was reworked and
new features added by Mike Coleman <mkc@acm.org> in 1999.
1999 Apr 3 WATCH(1)