我希望我在正确的地方发帖,我想我应该去linux区域,但这可能是一个代码问题。
我有以下 php 脚本:
<?php
use function commandscreateWalletsForMain;
use function commandscreditWallet;
use function commandsdebitWallet;
use function commandsgetConfig;
use function commandsselectAlts;
use function commandsselectMains;
use function commandsupdateConfig;
use function commandsselectUncreditedTransactions;
use function commandsselectWallet;
use function commandsupdateTransaction;
include_once '../vendor/autoload.php';
include_once '../processors/commands.php';
include_once '../secret/esiConn.php';
include_once '../secret/dbconn.php';
$newConn = createConnection();
$mains = selectMains($newConn);
$uncreditedTransactions = selectUncreditedTransactions($newConn);
use MonologLogger;
use MonologHandlerStreamHandler;
$log = new Logger('wallet');
$log->pushHandler(new StreamHandler("../processors/logs/wallet.log"));
if($uncreditedTransactions->rowCount() != 0) {
foreach ($uncreditedTransactions as $row) {
if(selectWallet($newConn,$row['character_id']) != null) {
creditWallet($newConn, $row['character_id'],$row['amount']);
updateTransaction($newConn,$row['transactionID']);
$log->warning($row['character_id']." credited with ".$row['amount']);
}
else
{
$log->warning("User has no wallet");
}
}
}
else
{
$log->warning("All transactions credited");
}
if(getConfig($newConn,'ProcessedMonth') == date("m") )
{
foreach ($mains as $row)
{
$totalALTS = selectAlts($newConn,$row['main_id'])->rowCount();
if(selectWallet($newConn,$row['main_id']) != null) {
debitWallet($newConn, $row['main_id'], ($totalALTS + 1) * 50000000);
$log->warning($row['main_id']." has been debited ".(($totalALTS + 1) * 50000000).' isk.');
}
else
{
$log->warning("User has no wallet");
}
}
updateConfig($newConn,'ProcessedMonth',date('m', strtotime('+1 month')));
}
foreach ($mains as $row) {
if(selectWallet($newConn,$row['main_id']) == null)
{
createWalletsForMain($newConn, $row['main_id']);
$log->warning('Wallet has been created for '.$row['main_id']);
}
}
closeConnection();
我在 apache2 服务器上添加了该文件,并在 crontab 中添加了以下行:
*/3 * * * * /usr/bin/php /var/www/eve/processors/wallet.php
但是它不执行它,我尝试在控制台中手动运行运行php /var/www/eve/processors/wallet.php
的代码,这确实触发了脚本并且它可以工作。
我有点迷茫...我已经尝试了 2 天来弄清楚....
设法解决了这个问题....我的代码实际上是问题所在。我的include_once磨损了这个事业,因为这些道路永远不应该这样宣布,现在我已经读到了它。我的坏:)