Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

events of job1 trigger action of job 2 #13

Open
gedeef opened this issue Mar 11, 2016 · 1 comment
Open

events of job1 trigger action of job 2 #13

gedeef opened this issue Mar 11, 2016 · 1 comment

Comments

@gedeef
Copy link

gedeef commented Mar 11, 2016

Hi,

I wrote a config file with two jobs for the same directory :

watcher.ini
[job_write]
watch=/some/dir
events=create,modify,move_to,write_close
recursive=true
autoadd=true
excluded=
command=/some/path/in_create.sh $filename $nflags $tflags

[job_delete]
watch=/some/dir
events=delete,move_from
recursive=true
autoadd=true
excluded=
command=/some/path/in_delete.sh $filename $nflags $tflags

The scripts called write logs and copy file to another server :

in_create.sh
#!/bin/bash
LOGFILE=/var/log/watcher.log
echo "$(date +%Y-%m-%d);$(date +%H:%M:%S);$1;$3;$2;in_create.sh" >> $LOGFILE
(...)

in_delete.sh
#!/bin/bash
LOGFILE=/var/log/watcher.log;
echo "$(date +%Y-%m-%d);$(date +%H:%M:%S);$1;$3;$2;in_delete.sh" >> $LOGFILE
(...)

I expect, when I create a directory or file, that only in_create.sh will be called, but the logs show that both scripts in_create and in_delete are called.

I found a workaround by joining the 2 jobs in one and making a script who checks the nature of events and redirects to the right script, but I guess this behaviour is not normal.

I see in my logs lines like this one :
$mkdir /some/dir/test

2016-03-11;13:16:18;/some/dir/test;IN_CREATE|IN_ISDIR;1073742080;in_create.sh
2016-03-11;13:16:18;/some/dir/test;IN_CREATE|IN_ISDIR;1073742080;in_delete.sh

The second line should not be there, should it ?

@suminus
Copy link

suminus commented Mar 11, 2016

hey gedeef,

that's the same way i solved that issue. i redirected the according commands to functions in
one event-handler-script. it's easier to maintain. the script uses arguments (bash: $1 $2 ...)
to sort e.g. $tflags.

cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants