How to check indexer mode is by scheduled or not programmatically in Magento 2?

Check whether the indexer is run by a schedule in Magento programmatically.

Magento has two types of Indexer mode, Update by schedule and Update on Save.

If we want to know about the specifically given type mode is by scheduled or not, we need to collect specific indexer id, like Indexer id, catalog_category_product we are checking the type of mode.

namespace Jesadiya\Indexer\Model;

use Magento\Framework\Indexer\IndexerRegistry;

class Mode
     * @var IndexerRegistry
    protected $indexerRegistry;

    public function __construct(
        IndexerRegistry $indexerRegistry
    ) {
        $this->indexerRegistry = $indexerRegistry;

     * @return bool
    public function isIndexerScheduled()
    	$isScheduled = false;
    	$indexerId = 'catalog_category_product';
    	try {
            $indexer = $this->indexerRegistry->get($indexerId);

            $isScheduled = $indexer->isScheduled()
        } catch (\InvalidArgumentException $e) {
        return $isScheduled;

Check the Result by calling the function,

$result = $this->isIndexerScheduled();

Output: bool

You can check any indexer value using the same approach with just pass your actual indexer id.

Check More Article,
An Indexer to used for Product Stock Update in Magento 2.