Create custom Drush command

Create in module directory file named drush.services.yml with similar content:

services:
  custom_base.commands:
    class: Drupal\custom_base\Commands\CustomCommands
    arguments:
      - '@config.factory'
      - '@entity_type.manager'
      - '@database'
    tags:
      -  { name: drush.command }

In Drupal\custom_base\src\Commands need to create file CustomCommands.php:

<?php

namespace Drupal\custom_base\Commands;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drush\Commands\DrushCommands;

/**
 * Drush commands for Custom Base module.
 */
class CustomCommands extends DrushCommands {

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Drupal\Core\Entity\EntityTypeManagerInterface definition.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Drupal\Core\Database\Connection definition.
   *
   * @var \Drupal\Core\Database\Connection
   */
  protected $connection;
  
  /**
   * CustomCommands constructor.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
   *   The config factory.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   The entity type manager.
   * @param \Drupal\Core\Database\Connection $connection
   *   Connection definition.
   */
  public function __construct(
    ConfigFactoryInterface $configFactory,
    EntityTypeManagerInterface $entityTypeManager,
    Connection $connection,
  ) {
    parent::__construct();
    $this->configFactory = $configFactory;
    $this->entityTypeManager = $entityTypeManager;
    $this->connection = $connection;
  }

  /**
   * A custom Drush command to update config variable.
   *
   * @command custom_base:update
   *
   * @aliases custom_base-update
   */
  public function customBaseUpdate() {
    $this->configFactory
      ->getEditable('custom_base.settings')
      ->set('time', time())
    $this->output->writeln(dt('Time config has been updated.'));
  }