openSUSE Forums > Programming/Scripting » OS File System Hooks?

Go Back   openSUSE Forums > Programming/Scripting
Forums FAQ Members List Search Today's Posts Mark Forums Read


Programming/Scripting Questions about programming, bash scripts, perl, php, cron jobs, ruby, python, etc.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-Oct-2009, 21:14
Puzzled Penguin
 
Join Date: Nov 2008
Posts: 44
Reg_gie hasn't been rated much yet
Default OS File System Hooks?

Hello,

I would like to run a script upon the creation of a directory with a particular name. While I could use 'find' or 'locate' on a cron that seems rather inefficient. Is there a way to 'hook' into the creation of a file or directory with a script?

I think there must be a way since 'locate' keeps its database up to date all the time.

I'm running OpenSuSE 11.0.

Thanks,
Reg
Reply With Quote
  #2 (permalink)  
Old 05-Oct-2009, 21:36
FeatherMonkey's Avatar
Wise Penguin
 
Join Date: Mar 2008
Posts: 1,545
FeatherMonkey has a spectacular reputation aura aboutFeatherMonkey has a spectacular reputation aura aboutFeatherMonkey has a spectacular reputation aura aboutFeatherMonkey has a spectacular reputation aura about
Default Re: OS File System Hooks?

inotify-tools should do the job... inotify-tools looks like pacman has it.
__________________
Man first, have a try at Info, have a look at Wiki, if all that fails Scroogle!!!!!
If I've helped click on the Rep button I don't know what it does but it sounds cool.
Reply With Quote
  #3 (permalink)  
Old 05-Oct-2009, 21:59
Puzzled Penguin
 
Join Date: Nov 2008
Posts: 44
Reg_gie hasn't been rated much yet
Default Re: OS File System Hooks?

Very cool, thanks.

It will allow me to make sure .svn directories have svn:svn ownership when created by other programs. E.g., during a checkout from an application like Aptana.

Just thought I would mention this in case anyone else comes across the same requirement and does a search.
Reply With Quote
  #4 (permalink)  
Old 06-Oct-2009, 03:26
palladium
Guest
 
Posts: n/a
Default Re: OS File System Hooks?

> I think there must be a way since 'locate' keeps its database up to
> date all the time.


as far as i know 'locate' keeps its db up to date using 'updatedb'
being triggered by a [default] once a day cron....

have you changed yours to an "all the time" cron...wouldn't that cause
a huge resources hit and drag your system down? [of course, your
system might be strong enough to do it constantly...mine would not be!]

--
palladium
Reply With Quote
  #5 (permalink)  
Old 06-Oct-2009, 17:54
Puzzled Penguin
 
Join Date: Nov 2008
Posts: 44
Reg_gie hasn't been rated much yet
Default Re: OS File System Hooks?

I've done nothing special with updatedb but locate seems to be up to date without me ever running updatedb so I just figured the SuSE people did something extra that is perhaps not so easy to find in the documentation.

In my case if it was on a cron, as long as it wasn't being run too often it probably wouldn't slow me down too much with a quad core 2.6 GHz processor. I find the quad core pretty much keeps the system smooth even when some process sucks up 100% of one of the cores on a thread and I have never seen Linux allow something to push more than one thread to 100% (although I am sure it is possible).

Usually they all just sit there and fluctuate between 1% - 10% usage or less if I close the system monitor and use something text only like htop.
Reply With Quote
  #6 (permalink)  
Old 06-Oct-2009, 20:36
Puzzled Penguin
 
Join Date: Sep 2009
Posts: 8
craverii hasn't been rated much yet
Default Re: OS File System Hooks?

It seems to me that the use of groups and sticky bits (i.e. chmod) on the parent directory where files and directories are created might be a simpler solution.
Reply With Quote
Reply

Bookmarks


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2