configuration – All of functionality is running , but if this code is on console command execute(), is not working

I am looking for magento 2 developer.
I need to build a extension that clear the cart every day by cron job.
So I made the extension for this work. all of the functionality is OK on testing mode

  • I made testing controller to clear cart. this is ok.
  • Also cron module is OK
  • command testing module is OK

But just when clearing cart function execute on cron or command, this function is not working.

   public function execute()
    {
        $objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $cart = $objectManager->get('MagentoCheckoutModelCart');
        $allItems = $cart->getQuote()->getAllVisibleItems();
        foreach ($allItems as $item) {
            $itemId = $item->getItemId();
            $cart->removeItem($itemId)->save();
        }
}

this code is for controller. this functionality is running

protected function execute(
        InputInterface $input,
        OutputInterface $output
    ) {
        $output->writeln("Clear cart from cmd: start");

    }

this code is for command. printed “Clear cart from cmd: start” message

But when execute below code, this function is not running

$objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $cart = $objectManager->get('MagentoCheckoutModelCart');
        $allItems = $cart->getQuote()->getAllVisibleItems();
        foreach ($allItems as $item) {
            $itemId = $item->getItemId();
            $cart->removeItem($itemId)->save();
        }

like

    protected function execute(
        InputInterface $input,
        OutputInterface $output
    ) {
        $this->_appState->setAreaCode('frontend');
        $objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $cart = $objectManager->get('MagentoCheckoutModelCart');
        $allItems = $cart->getQuote()->getAllVisibleItems();
        foreach ($allItems as $item) {
            $itemId = $item->getItemId();
            $cart->removeItem($itemId)->save();
            $output->writeln("Clear cart from cmd: start2");
        }
    }

How can I run this function?