chdir(\''. $path . '/protected\');
';
// Set the working directory correctly
chdir('Enter the determined path here');
// Define the full path to the PHP execution and the yii file
$command = '/usr/bin/php '. $path . '/protected/yii log/clear "-2 days" 2>&1';
// Create variables for the output and return value
$output = [];
$return_var = 0;
// Run the command
exec($command, $output, $return_var);
// Output of the command (useful for debugging purposes)
echo "
";
echo "command executed: $command
";
echo "output:
" . implode("
", $output) . "
";
echo "return value: $return_var
";
// Check if the command was successful
if ($return_var === 0) {
echo "The command was executed successfully. Logs older than 2 days were deleted.
";
} else {
echo "There was an error executing the command. Please check the details.
";
}
// Check if the output is empty
if (empty($output)) {
echo "No specific output was obtained from the command. The command may have succeeded without any console output.
";
}
?>