LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-15-2009, 03:50 AM   #1
s8utt
LQ Newbie
 
Registered: Aug 2005
Posts: 4

Rep: Reputation: 0
Detect presence of a file


I have a directory where files are created to be run by a different user. ( Web process creates the file, need a user to run it )

I have a script that I have set on a cron job to run every 5 mins.

Code:
cd /REMOTE
for i in /REMOTE/*; do 
if [ -f $i ]; then 
# if the file is there 
filename=${i#/REMOTE/}
./$filename
mv $filename /REMOTE/Ran
fi 
done

IS there anyway to have a process running that will monitor the presence of files in the directory and run them when they appear ?

I want to feedback to the webpage that the script has been run but at the moment they get no indication until the cron job runs which can be upto 5 minutes away.
This means they have to refresh the browser screen 5 minutes later.

Any suggestions would be great.

Thanks

Last edited by s8utt; 05-15-2009 at 03:52 AM.
 
Old 05-15-2009, 04:00 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
You can use a utility called incrontab for that. http://inotify.aiken.cz/?section=inc...=about&lang=en
 
Old 05-15-2009, 04:03 AM   #3
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
inotifywait, example:

Code:
inotifywait -m --format %f --event create ~/tmp | while read newfile; do echo "A new file has been created: $newfile"; done
 
Old 05-15-2009, 04:37 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
...and for kernels or platforms without inotify there's watchfolder. (Note the link is to sfr-fresh.com since Freshmeat project page is gone and the app is available from some .*BSD and Linux distribution repo's.)
 
Old 05-19-2009, 03:34 AM   #5
s8utt
LQ Newbie
 
Registered: Aug 2005
Posts: 4

Original Poster
Rep: Reputation: 0
spent all yesterday trying to get incron installed never mind working

I have SuSE Linux 9.2 (x86-64)

I couldn't find a rpm for this and the tar file I downloaded I couldn't figure out how to install it

Can anyone shed some light or help me out
Thanks

Last edited by s8utt; 05-20-2009 at 06:41 AM.
 
Old 05-19-2009, 03:47 AM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
For inotifywait, in Gentoo it comes into a package called inotify-tools. Maybe it's something similar for your distro. If not, this is their site:

http://inotify-tools.sourceforge.net/
 
Old 05-20-2009, 06:41 AM   #7
s8utt
LQ Newbie
 
Registered: Aug 2005
Posts: 4

Original Poster
Rep: Reputation: 0
could not find anything for Suse 9.2

Tried installing this one

incron-0.5.6-1.guru.suse101.x86_64.rpm

but got the following error.
Code:
error: Failed dependencies:
        libc.so.6(GLIBC_2.4)(64bit) is needed by incron-0.5.6-1.guru.suse101
        libstdc++.so.6()(64bit) is needed by incron-0.5.6-1.guru.suse101
        libstdc++.so.6(CXXABI_1.3)(64bit) is needed by incron-0.5.6-1.guru.suse101
        libstdc++.so.6(CXXABI_1.3.1)(64bit) is needed by incron-0.5.6-1.guru.suse101
        libstdc++.so.6(GLIBCXX_3.4)(64bit) is needed by incron-0.5.6-1.guru.suse101
any suggestions ?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
confirmaion for the allocated memory presence chakka.lokesh Programming 2 08-14-2008 12:46 AM
Info on finding ECC presence sthirumalai Linux - Kernel 0 06-26-2006 08:25 AM
Does Your Old School Have A Web Presence? XavierP General 16 05-24-2005 08:40 AM
Detect file changes? x5452 Linux - General 9 04-18-2004 02:45 PM
how to detect floppy presence Shirley Linux - General 1 05-15-2002 08:14 AM


All times are GMT -5. The time now is 10:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration