trouble getting incron inotify to work


so after alex answer here are my steps :

creating shell code

[email protected][/]# touch
[email protected][/]# nano

copying the code in the

echo "File $1 created." >> /mylog.log


[email protected][/]# chmod +x

creating the log file

[email protected][/]# touch mylog.log 

opening icron table

incrontab -e

putting new command in

/test/ IN_CREATE [email protected]$#

reloading incron – creating a new file – checking the log file

[email protected][/]# incrontab --reload
requesting table reload for user 'root'...
request done

[email protected][/]# cd test
[email protected][/test]# touch newfile.txt

[email protected][/test]# cd /
[email protected][/]# nano mylog.log

but still empty log file … am i missing something ?

finally calling shell script with full path did the trick
so :

/test/ IN_CREATE / [email protected]$#


You can usually find the incron logs in /var/log/messages

If you want to log events to a specific file you can use:

/test/ IN_CREATE [email protected]$#

where is a shell script which handles the logging.

echo "File $1 created." >> /home/myuser/filescreated.log

Don’t forget to give execution permission to this shell script by chmod +x

As soon as you start using parameters for your command which you’re calling, you have to put it all into a shell script. Since incron don’t pass the arguments to your command but interprets it as an argument for itself.

Don’t forget to call incrontab –reload after changing the incrontab.

Another example

incrontab -e

/text/ IN_CREATE /home/myuser/ [email protected] $#

echo "$(date) File $2 in $1 created." >> /home/myuser/log.txt

Answered By – Alexander Baltasar

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published