Operating System - Linux
1748210 Members
2809 Online
108759 Solutions
New Discussion юеВ

Re: Catch automatically new files in a particular folder

 
Leo The Cat
Regular Advisor

Catch automatically new files in a particular folder

Hi Guys

I've another small affair.
How to catch any new core file in my folder /wrk/files ?

I'd like to trigger actions when core file is coming. Of course I can do this we a crontab and check if a new file is arrived from the last check but the problem is that in a minute many core will arrived and the risk is to missed some files ! The last core file is always overwriten and I want to have all files. So I need first to rename the file...

Any Idea ?

Bests Regards
Den
8 REPLIES 8
Ivan Ferreira
Honored Contributor

Re: Catch automatically new files in a particular folder

The first I can think is a versioning file system:

http://en.wikipedia.org/wiki/Versioning_file_system

Another very more complex option is to enable auditing. After an event for that file is detected, use swatch to trigger an action.

But remember, keep it simple and it will work.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
smatador
Honored Contributor

Re: Catch automatically new files in a particular folder

Hi,

I never use for this task but maybe you could implement rsync daemon with some configuration tasks like backup for renaming your core file.
Thierry D
Valued Contributor

Re: Catch automatically new files in a particular folder

Hi Leo,

You could have a look at incron, which is a kind of cron but based on file system event and not time event.

http://inotify.aiken.cz/?section=incron&page=aboutтМй=en


Cheers
Thierry
Dennis Handly
Acclaimed Contributor

Re: Catch automatically new files in a particular folder

>How to catch any new core file in my folder /wrk/files?

Shouldn't you be trying to find why you have so many?
If linux had coreadm, you could have them moved elsewhere and with unique names.
Srimalik
Valued Contributor

Re: Catch automatically new files in a particular folder

you can use dnotify/inotify theese function allow you to monitor changes to your filesystem.

Not sure if a pre-written tool is available for which alllows you to directly specify directory names to monitor on command line.

You may have to write C program using these APIs

Thanks
Sri
abandon all hope, ye who enter here..
Jeroen Peereboom
Honored Contributor

Re: Catch automatically new files in a particular folder

L.S.

not really an answer to your question, but I agree with Dennis: solve the problem or have it solved.

Why is it so important not to miss a single core file?

JP
Srimalik
Valued Contributor

Re: Catch automatically new files in a particular folder

you can set 1 in /proc/sys/kernel/core_uses_pid so that every core file is appended with the pid of the dumping process.
abandon all hope, ye who enter here..
Jeroen Peereboom
Honored Contributor

Re: Catch automatically new files in a particular folder

Well,

that's a nice, easy solution of Srikrishan.

JP