Log path in var

This commit is contained in:
Michael RICOIS 2017-03-02 14:37:05 +01:00
parent 8ce26eea1c
commit b6c544a97a
4 changed files with 16 additions and 10 deletions

6
README
View File

@ -46,13 +46,13 @@ Crontab - incron
================ ================
Exemple surveillance livraison de fichiers par le client Exemple surveillance livraison de fichiers par le client
$fluxBasePath IN_CLOSE_WRITE php /home/batchFlux/fileSend.php --file $@/$# >> /home/log/send.log 2>&1 $fluxBasePath IN_CLOSE_WRITE php /home/batchFlux/fileSend.php --file $@/$# >> /home/flux/shared/send.log 2>&1
Exemple surveillance lecture du fichier mis en dépot Exemple surveillance lecture du fichier mis en dépot
$fluxBasePath IN_CLOSE_NOWRITE,IN_ACCESS,IN_DELETE,IN_NO_LOOP php /home/batchFlux/fileRead.php --file $@/$# >> /home/log/read.log 2>&1 $fluxBasePath IN_CLOSE_NOWRITE,IN_ACCESS,IN_DELETE,IN_NO_LOOP php /home/batchFlux/fileRead.php --file $@/$# >> /home/flux/shared/read.log 2>&1
Exemple surveillance retour par autre programme de transmission Exemple surveillance retour par autre programme de transmission
$fluxBasePath IN_CLOSE_WRITE php /home/batchFlux/fileTck.php --file $@/$# >> /home/log/tck.log 2>&1 $fluxBasePath IN_CLOSE_WRITE php /home/batchFlux/fileTck.php --file $@/$# >> /home/flux/shared/tck.log 2>&1
Attention, une seule entrée de repertoire peut être saisie dans la incrontab. Attention, une seule entrée de repertoire peut être saisie dans la incrontab.
fileSend a été prévue pour gérer correctement les extension tck fileSend a été prévue pour gérer correctement les extension tck

View File

@ -41,6 +41,8 @@ if ($displayUsage) {
exit; exit;
} }
$logPath = realpath(__DIR__ . '/../shared');
$prestations = include APPLICATION_PATH . '/../config.php'; $prestations = include APPLICATION_PATH . '/../config.php';
if ($opts->list) if ($opts->list)
@ -86,7 +88,7 @@ if ($opts->generate)
} }
$fluxBasePath = '/home/data/' . strtolower($item['type']) . '/' . $client . '/' . $directory; $fluxBasePath = '/home/data/' . strtolower($item['type']) . '/' . $client . '/' . $directory;
$file = __DIR__ . '/incron.d/' . strtolower($item['type']) . '_' . $client; $file = __DIR__ . '/incron.d/' . strtolower($item['type']) . '_' . $client;
file_put_contents($file, "$fluxBasePath IN_CLOSE_WRITE php /home/flux/current/send.php --file $@/$# >> /home/log/send.log 2>&1"); file_put_contents($file, "$fluxBasePath IN_CLOSE_WRITE php /home/flux/current/send.php --file $@/$# >> $logPath/send.log 2>&1");
echo "File created $file\n"; echo "File created $file\n";
} }
} }
@ -112,7 +114,7 @@ if ($opts->generate)
} }
$fluxBasePath = '/home/data/' . strtolower($item['type']) . '/' . $client. '/' . $directory; $fluxBasePath = '/home/data/' . strtolower($item['type']) . '/' . $client. '/' . $directory;
$file = __DIR__ . '/incron.d/' . strtolower($item['type']) . '_' . $client . '_recv'; $file = __DIR__ . '/incron.d/' . strtolower($item['type']) . '_' . $client . '_recv';
file_put_contents($file, "$fluxBasePath IN_ACCESS php /home/flux/current/read.php --file $@/$# >> /home/log/read.log 2>&1"); file_put_contents($file, "$fluxBasePath IN_ACCESS php /home/flux/current/read.php --file $@/$# >> $logPath/read.log 2>&1");
echo "File created $file\n"; echo "File created $file\n";
} }
} }

View File

@ -45,6 +45,8 @@ if ($displayUsage) {
exit; exit;
} }
$logPath = realpath(__DIR__ . '/../shared');
// --- Get the file // --- Get the file
if ( isset($opts->file) ) if ( isset($opts->file) )
{ {
@ -67,7 +69,7 @@ if ( isset($opts->file) )
} }
// --- Don't play with *.tck files // --- Don't play with *.tck files
if ($extension == 'tck') { if ($extension == 'tck') {
passthru(__DIR__ . '/tck.php --file '.$opts->file.' >> /home/log/tck.log 2>&1'); passthru(__DIR__ . '/tck.php --file '.$opts->file.' >> '.$logPath.'/tck.log 2>&1');
exit; exit;
} }
$client = basename(dirname($pathParts['dirname'])); $client = basename(dirname($pathParts['dirname']));

View File

@ -45,6 +45,8 @@ if (empty($opts->file)) {
exit; exit;
} }
$logPath = realpath(__DIR__ . '/../shared');
$pathParts = pathinfo($opts->file); $pathParts = pathinfo($opts->file);
$filename = $pathParts['basename']; $filename = $pathParts['basename'];
$extension = $pathParts['extension']; $extension = $pathParts['extension'];
@ -53,16 +55,16 @@ switch($opts->event)
{ {
case 'IN_CLOSE_WRITE': case 'IN_CLOSE_WRITE':
if ($extension == 'tck') { if ($extension == 'tck') {
passthru(__DIR__ . '/tck.php --file '.$opts->file.' >> /home/log/tck.log 2>&1'); passthru(__DIR__ . '/tck.php --file '.$opts->file.' >> '.$logPath.'/tck.log 2>&1');
} else { } else {
passthru(__DIR__ . '/send.php --file '.$opts->file.' >> /home/log/send.log 2>&1'); passthru(__DIR__ . '/send.php --file '.$opts->file.' >> '.$logPath.'/send.log 2>&1');
} }
break; break;
case 'IN_ACCESS': case 'IN_ACCESS':
case 'IN_CLOSE_NOWRITE': case 'IN_CLOSE_NOWRITE':
passthru(__DIR__ . '/read.php --file '.$opts->file.' >> /home/log/read.log 2>&1'); passthru(__DIR__ . '/read.php --file '.$opts->file.' >> '.$logPath.'/read.log 2>&1');
break; break;
case 'IN_DELETE': case 'IN_DELETE':
passthru(__DIR__ . '/read.php --file '.$opts->file.' >> /home/log/read.log 2>&1'); passthru(__DIR__ . '/read.php --file '.$opts->file.' >> '.$logPath.'/read.log 2>&1');
break; break;
} }