|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Are there any command that will check file ????
Hi all,
i will write a script. Script will sense certain directory and if a file is created it will send me an email. i know how mail is sent. But i dont know which command that check directory for file is created or not continuously. Thanx for your helping. ---------- Post updated at 04:19 AM ---------- Previous update was at 04:17 AM ---------- shortly, when someone created or send a file to certain directory my script have to send me a email. ---------- Post updated at 04:19 AM ---------- Previous update was at 04:19 AM ---------- how can i success this? |
| Sponsored Links | ||
|
|
|
#2
|
|||
|
|||
|
If you can do perl programming, then take a look at file::monitor: File::Monitor - search.cpan.org
|
|
#3
|
||||
|
||||
|
You can check with test if a file exists; example: Code:
[[ -e somefile ]] && echo ok Can also include it into a if/then/fi of course, etc. To have some repeating checks you might want to add it as a cron job. For cron you might read up here: cron and crontab |
|
#4
|
|||
|
|||
|
i know these ways, i curious are there any command?
Thanx. i know two way: 1-i write "[[ -e somefile ]] && echo ok" sentence in a script and call it via cron per 1 minute 2- i write "[[ -e somefile ]] && echo ok" sentence in a scirpt and call it in while loop. and there is "sleep 60" command in loop. i had curioused are there any command(will run backgroun of OS) sense directory for file. thanx |
|
#5
|
|||
|
|||
|
i dont believe such a process is there in any OS.. why at all it is required, then it will become a resource intensive in a heavily used file servers.
|
|
#6
|
|||
|
|||
|
2 ways I firgured out to meet your needs:
1) check the stimestamp of the directory ( Because once a file created, the directory's modification time is necessarily updated ). Save the the last timestamp and compare the most recent one to it to see if the timestamp has been changed 2) Use checksum (cksum command)... briefly, compare old checksum of the contents of the directory with the new checksum if the there is a change. If yes, new file has been created in that dir. The detailed code may look like this: Quote:
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| one line command to check file existence and FTP it | Codesearcher | Shell Programming and Scripting | 6 | 05-12-2009 08:06 PM |
| How can I make the for command check to see if a file is empty before executing? | chrchcol | Shell Programming and Scripting | 3 | 07-29-2006 03:14 AM |
| Script to check for a file, check for 2hrs. then quit | mmarsh | UNIX for Dummies Questions & Answers | 2 | 09-16-2005 02:46 PM |
| command for check CPU | abcde | UNIX for Dummies Questions & Answers | 2 | 05-09-2005 11:47 AM |
| command to check the bit | raguramtgr | UNIX for Dummies Questions & Answers | 2 | 07-12-2004 10:38 AM |