Собственно, сабж. Конечно, скрипт надо запускать из консоли, иначе никаких ресурсов не хватит.

Полезен, например, при переезде на новый сервер.

Код скрипта

<?php
 
$_SERVER['DOCUMENT_ROOT'] = '/var/www/site.ru';
 
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
 
$domainName = 'http://www.site.ru';
 
$iblockIds = [
    2,
];
 
$pageNum = 20;
 
define('NO_KEEP_STATISTIC', true);
 
define('NOT_CHECK_PERMISSIONS', true);
 
define('CHK_EVENT', true);
 
require($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php');
 
@set_time_limit(0);
 
@ignore_user_abort(true);
 
if (\Bitrix\Main\Loader::includeModule('iblock')) {
 
    $urls = [];
 
    foreach ($iblockIds as $iblockId) {
 
        $sectionIterator = CIBlockSection::GetList(
            [],
            [
                'IBLOCK_ID' => $iblockId,
                'ACTIVE' => 'Y',
                'GLOBAL_ACTIVE' => 'Y',
            ],
            [
                'ELEMENT_SUBSECTIONS' => 'Y',
                'CNT_ACTIVE' => 'Y',
            ],
            [
                'ID',
                'IBLOCK_ID',
                'SECTION_PAGE_URL'
            ]
        );
 
        while ($section = $sectionIterator->GetNext()) {
            for ($i = 1, $count = ceil($section['ELEMENT_CNT'] / $pageNum); $i <= $count; $i++) {
                $urls[] = sprintf('%s?PAGEN_1=%d', $domainName . $section['SECTION_PAGE_URL'], $i);
            }
        }
 
        $elementIterator = CIBlockElement::GetList(
            [],
            [
                'IBLOCK_ID' => $iblockId,
                'ACTIVE' => 'Y',
            ],
            false,
            false,
            [
                'ID',
                'IBLOCK_ID',
                'DETAIL_PAGE_URL'
            ]
        );
 
        while ($element = $elementIterator->GetNext()) {
 
            $urls[] = $domainName . $element['DETAIL_PAGE_URL'];
 
        }
 
    }
 
 
    foreach ($urls as $url) {
 
        @file_get_contents($url);
 
        @file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/import.log', $url . "\n", FILE_APPEND);
 
    }
 
 
}

Пример запуска php-скрипта из консоли:

$ php -f /var/www/site.ru/import.php &