Reputation: 2383
I am using incron to monitor one of my file in /var/www/html
directory.
output of incrontab -l
/var/www/html/test IN_ACCESS /home/intel/test.sh
This job is supposed to create a file in home directory, But when this job got executed (I opened the web address in browser), no file is created, following line is whon shown in /var/log/cron
file
Jan 20 10:27:57 localhost incrond[26442]: (root) CMD (/home/intel/test.sh)
This clearly shows that event had occurred.
P.S: If I just run a /home/intel/test.sh
in CLI its works fine and creates test file, following is my test.sh file.
#!/bin/bash
touch fm00
Upvotes: 2
Views: 2316
Reputation: 1583
Mostly this problem occurs due to script file permission and ownership of script files. The same problem was faced by me. I found that my scrip owner was not a super user e.g. root.
So, you have to set the permission and ownership of your scrip as super user. Find below.
First of all edit your crontab as super user.(in RHEL like below)
[abc@host] crontab -e
and save crontab :wq!
Now set permission for script
[abc@host] chmod +x script.sh
[abc@host] chown root:root script.sh
Now restart your crontab.(in RHEL like below)
[abc@host] /etc/init.d/crond restart
Upvotes: 5