1

I'm using CentOS on a VPS, I have installed Incron to watch a folder for file uploads, this is the incrontab -e command I'm using :

/home/user/public_html/uploads IN_CLOSE_WRITE /usr/bin/php /home/user/public_html/uploads/watcher.php $#

//The $@ sends the file name as montioned in the Icron tutorial here :

Incron tuto 1 Incron tuto 2

this is the content of watcher.php

<?php
$myfile = fopen("text.txt", "a") or die("Unable to open file!");
fwrite($myfile, $argv[1]."\n");//Argument 1 is the name of the file, argv[0] is the script name.
fclose($myfile);   

when I upload one file "myphpfile.php" Icron works and saved the name in the "text.txt" file however when I open it I found so many lines with the name of the file uploaded :

text.txt :
myphpfile.php
myphpfile.php
myphpfile.php
myphpfile.php
myphpfile.php
.....

I'm uploading only one file, the "text.txt" file should have only one line, I know I could open the file using "w" but this will only delete all entries and save the last one. I mean using appened "a" shows that something is wrong with Incron when uploading files using "IN_CLOSE_WRITE" as watch event. I can't find any event to handle upload files. Can you help me please?

Thanks.

oussama kamal
  • 1,027
  • 2
  • 20
  • 44
  • Find a sulution my self. For those how may be interested : just had to add IN_NO_LOOP after "IN_CLOSE_WRITE" like this : /home/user/public_html/uploads IN_CLOSE_WRITE, IN_NO_LOOP /usr/bin/php /home/user/public_html/uploads/watcher.php $# – oussama kamal Sep 05 '15 at 12:58

0 Answers0