Files
ms1inscription-v5/auto_chronotrack_sync.php

51 lines
1.5 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* MSIN-4328 — Cron sync auto ChronoTrack (différentiel).
*
* Même pattern que auto_liste_attente.php :
* /usr/bin/curl -s https://VOTRE-DOMAINE/auto_chronotrack_sync.php > /dev/null 2>&1
*
* Minute=* Hour=* … → le script décide selon fréquence/fin de chaque event.
*/
ini_set('display_errors', 0);
ini_set('log_errors', 1);
ini_set('error_log', __DIR__ . '/log/php_log.txt');
@set_time_limit(300);
$strLockPath = rtrim(sys_get_temp_dir(), '/\\') . DIRECTORY_SEPARATOR . 'ms1_chronotrack_auto_sync.lock';
$fpLock = @fopen($strLockPath, 'c');
if ($fpLock === false || !flock($fpLock, LOCK_EX | LOCK_NB)) {
if (is_resource($fpLock)) {
fclose($fpLock);
}
header('Content-Type: text/plain; charset=utf-8');
echo 'busy';
exit;
}
session_start();
try {
require_once __DIR__ . '/php/inc_fonctions.php';
require_once __DIR__ . '/php/chronotrack_api/inc_bootstrap.php';
$arrResult = fxChronotrackApiSyncRunAutoCron();
$strLine = 'auto_chronotrack_sync [' . date('Y-m-d H:i:s') . '] '
. ($arrResult['message'] ?? 'done');
// Même style que liste dattente : une ligne dans log/php_log.txt
error_log($strLine);
header('Content-Type: text/plain; charset=utf-8');
echo $strLine . "\n";
} catch (Throwable $ex) {
$strErr = 'auto_chronotrack_sync ERROR [' . date('Y-m-d H:i:s') . '] ' . $ex->getMessage();
error_log($strErr);
header('Content-Type: text/plain; charset=utf-8');
echo $strErr . "\n";
}
flock($fpLock, LOCK_UN);
fclose($fpLock);