LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-15-2002, 01:27 AM   #1
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Rep: Reputation: 30
Linux command to montior a folder


Hello
Is there any Linux command to monitor a folder,and identify when a new folder is added to the folder or when a file is deleted from the folder.

Regards
Saravanan
 
Old 06-15-2002, 01:42 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
No command that I know of would do that... I think most likely you would have to make a script and then setup a cron job to run however often you want (every hour, day... etc) for it to check the folder for changes.... etc.
 
Old 06-15-2002, 02:24 AM   #3
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Original Poster
Rep: Reputation: 30
okay then can u tell me the linux cmd to find the total space in a folder, and total number of files in it.

Regards
Saravanan
 
Old 06-15-2002, 02:55 AM   #4
sakeeb
Member
 
Registered: Apr 2002
Posts: 270

Rep: Reputation: 31
df will tell you the diskfree status. du can be used to get the disk space usage of a file or directory.
 
Old 06-15-2002, 07:08 AM   #5
geoffm33
Member
 
Registered: May 2002
Distribution: RH 7.3 - YDL 2.3
Posts: 63

Rep: Reputation: 15
du is right.

use it like this for a long list of files with their respective sizes in human readable form of the current working directory:

$bash> du -h .


use it like this for a summary mode output of the size of all the files in human readable form of the current working directory:

$bash> du -sh .


(Substitute the dir you want to analyze where the dot is above)
 
Old 06-15-2002, 07:26 AM   #6
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Original Poster
Rep: Reputation: 30
Dear Geofmm and sakeeb
Thanks a lot for ur reply.But dont we have any cmd in Linux similar to the Windows NT API functions which identifies when a file in a directory is added ,Edited or deleted.
 
Old 06-15-2002, 08:43 AM   #7
geoffm33
Member
 
Registered: May 2002
Distribution: RH 7.3 - YDL 2.3
Posts: 63

Rep: Reputation: 15
Have a look at tripwire though. When configured properly, it will tell you when a file has been added or deleted.

This shell script will summarize the action of a directory that is passed via the command line:

Quote:
#!/bin/bash

FILES=`find $1 -type f 2>/dev/null | wc -l`
DIRS=`find $1 -type d 2>/dev/null | wc -l`
SIZE=`du -sh $1 2>/dev/null`

echo "The total number of files in $1: $FILES"
echo "The total number of directories under $1: $DIRS"

echo "The total size of all files in $1: $SIZE"
run like this:

$bash> ./summary.sc /home/user1

Run intermittenly, you can see part of what you are after.

It is far from acurate if not run as superuser because it only reports on dirs you have permissions to. All errors are output to /dev/null.


IHTH
 
Old 06-17-2002, 10:34 AM   #8
saravanan1979
Member
 
Registered: Jan 2002
Posts: 163

Original Poster
Rep: Reputation: 30
Dear Geofmm i am running Red Hat Linux 6.2,trip wire offers a speparate set of linux,anyway thanks a lot for ur shell script it does give me the total number of files and folders,for a given directory,but how do i retreive a new file that has been added to a directory.Of course i am going to run ur shell in a cron job,find out the previous file count ,current file count and by the difference and come to no that a new file has been added but how do i check for the created time.As far as i have checked i can find only Modified time,Last changed time and access time but there is no created time.Please let me know these details
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command to forward files to folder TubeScreamer Linux - Newbie 3 08-03-2005 02:57 PM
Command folder size Ataraxos Linux - Newbie 8 04-03-2005 12:09 PM
remove folder from command line demmylls Linux - General 3 02-15-2004 09:52 AM
rename file/folder command hct224 Linux - Newbie 4 09-19-2003 09:44 AM
change folder command eduac Linux - Software 4 07-14-2003 08:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration