LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command associated with Incron not getting executed (https://www.linuxquestions.org/questions/linux-newbie-8/command-associated-with-incron-not-getting-executed-4175461947/)

Bharath_ 05-14-2013 12:54 PM

Command associated with Incron not getting executed
 
Hi,

I am trying to synchronize my servers using unison. I have a master and slave pattern. So when i make changes in the master i want my unison script to be executed. I am using incrontab -e to watch my folder and have put this line inside it /usr/share/nginx/html IN_ALL_EVENTS /bin/sh /root/scripts/sync.sh

But when i make changes in my html folder the abouve statement is not getiing executed. When i see the log i get a message

May 14 12:52:36 Nginx1 incrond[15788]: (root) CMD ( /bin/sh /root/scripts/sync.sh)
May 14 12:52:36 Nginx1 incrond[15788]: (root) CMD ( /bin/sh /root/scripts/sync.sh)
May 14 12:52:36 Nginx1 incrond[15792]: cannot exec process: No such file or directory
May 14 12:52:36 Nginx1 incrond[15793]: cannot exec process: No such file or directory
May 14 12:52:41 Nginx1 incrond[15788]: (root) CMD ( /bin/sh /root/scripts/sync.sh)
May 14 12:52:41 Nginx1 incrond[15795]: cannot exec process: No such file or directory

Can anyone tell me why my statement is not getting executed..

Kenarkies 05-14-2013 07:14 PM

Well I don't really want to be seen to be stating the obvious, but I assume you have verified that /root/scripts/sync.sh does exist (watch spelling and upper/lower case) and is executable. Sometimes a small spelling error just seems to be invisible to even the most experienced user. Also are there any references to paths within sync.sh that might be invalid?

Probably a good idea to move the script out of the root home directory but that's only an opinion. It shouldn't make a difference where it is put as long as it is accessible.

chrism01 05-14-2013 07:40 PM

It looks like there's something in the sync.sh script that cron doesn't like.
You could check your email on the box to (or root's) to see if it sent you an email.
Try using bash instead of sh; its more capable. Put it at the top of the script thus '#!/bin/bash' and drop the external call.
Add 'set -xv' next at the top of the script; it'll show you what the parser sees/does & then ensure you capture stdout+stderr to a file to check results.
Code:

/usr/share/nginx/html IN_ALL_EVENTS  /root/scripts/sync.sh >/tmp/sync.log 2>&1

Bharath_ 05-15-2013 11:44 AM

Hi chrism01,

I tried /usr/share/nginx/html IN_ALL_EVENTS /root/scripts/sync.sh >/tmp/sync.log 2>&1
But i noticed that there was no file created in /tmp. I think the command is not getting executed. how can i solve this..


All times are GMT -5. The time now is 12:52 AM.