Fsniper is a useful tool for directory monitor, and execute predefined actions on files created or modified in that directory
Fsniper Installation
First we need to install require package for Fsniper
[root@manivel ~]# yum install file-libs file-devel pcre pcre-devel
Download Fsniper source blow link
[root@manivel ~]# wget http://projects.l3ib.org/fsniper/files/fsniper-1.3.1.tar.gz
[root@manivel ~]# tar xzf fsniper-1.3.1.tar.gz
[root@manivel ~] cd fsniper-1.3.1/
Compile and Install Fsniper from source using below command
[root@fsniper-1.3.1] ./configure
[root@fsniper-1.3.1] make
[root@fsniper-1.3.1] make install
Fsniper Configuration
Open fsniper config file and change the path which directory need to monitor
[root@fsniper-1.3.1] vim /root/.config/fsniper/config
watch {
# watch the "/test/django/test/media" directory for new files
/test/django/test/media {
recurse = true
# matches any file ending with .php
*.php {
# remove files with extension .php
handler = rm -f %%
}
*.html {
# remove files with extension .html
handler = rm -f %%
}
*.htm {
# remove files with extension .htm
handler = rm -f %%
}
}
Start Fsniper as Daemon using below command
[root@manivel ~]# fsniper --daemon
We can check the fsniper process id
[root@manivel ~]# pgrep fsniper
13080
[root@manivel ~]#
No comments:
Post a Comment