A
A
Anatoly2019-01-21 00:35:36
linux
Anatoly, 2019-01-21 00:35:36

Does anyone use the watcher.py daemon?

It's an event tracker, like incron, but with subfolder recursion.
Homepage : https://github.com/gregghz/Watcher
when the file is moved to the watch folder.
When an event occurs, some command is called, I call a bash file.
The bash file calls the second bash file, provided it is not already running.
The question is, if I move 20 files, then the daemon monitors the first file and starts bash,
which checks to see if the second bash file is running. The second file is copied almost immediately after the first, bash is started and instead of exiting, since the second bash is already running, it waits for it to finish to run it.
And so all 20 files, why does it not complete, but waits?
Bash file that starts the daemon:

#!/bin/bash
#
# Проверяем, запущен ли optimize.sh, если нет, то запускает его
if pgrep -x optimize.sh > /dev/null; then
    echo "Passed.." >> /var/www/oo.log
else
    echo "Смотрим процессы: " `pgrep -c "optimize.sh"` >> /var/www/oo.log
    /var/www/optimize.sh create
fi

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2019-01-21
@Tolly

I close the question, the problem was that the second script was launched sequentially, and until it was executed, no other actions took place in the first script, so exit did not work, for the same reason there was not more than one "Passed .."
solution in the logs like this: running the script not sequentially, but in the background, then control is transferred to the next command, and do whatever you like ..
The script should have been run as: optimize.sh &

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question