How can I remove old articles?
The code I would use is similar to the following one.

$entity_query = new EntityFieldQuery();
$entity_query-&gt;entityCondition('entity_type', 'node')
  -&gt;entityCondition('bundle', 'article')
  -&gt;entityCondition('created', strtotime('1 January 2019'), '&lt;')
  -&gt;addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
$result = $entity_query-&gt;execute();
if (isset($result['node'])) {
  node_delete_multiple(array_keys($result['node']));
}


The differences between the code I am using and the code shown in the answers for Delete a node after X weeks it was created are the following:


The object used to query the entity is instantiated differently and its class is different
The code doesn't select just the published nodes (I take you are interested in deleting all the nodes created before 2019)
The code is using addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT') to get all the nodes, even the ones to which the currently logged-in user doesn't have access (Remember that cron tasks are executed as anonymous user, which possibly doesn't have access to many of the nodes)
In Drupal 7, the functions to delete nodes are node_delete() and node_delete_multiple() which require, respectively, a node ID and an array of node IDs


If I were to do the task in a hook_cron() implementation, I would use the following code.

  function mymodule_cron() {
    $entity_query = new EntityFieldQuery();
    $entity_query-&gt;entityCondition('entity_type', 'node')
      -&gt;entityCondition('bundle', 'article')
      -&gt;entityCondition('created', strtotime('1 January 2019'), '&lt;')
      -&gt;addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT')
      -&gt;range(0, 25);
    $result = $entity_query-&gt;execute();
    if (isset($result['node'])) {
      node_delete_multiple(array_keys($result['node']));
    }
  }


Older Drupal 7 versions would need to replace addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT') with addMetaData('account', user_load(1)). For those versions the code would be then similar to the following one.

  function mymodule_cron() {
    $entity_query = new EntityFieldQuery();
    $entity_query-&gt;entityCondition('entity_type', 'node')
      -&gt;entityCondition('bundle', 'article')
      -&gt;entityCondition('created', strtotime('1 January 2019'), '&lt;')
      -&gt;addMetaData('account', user_load(1))
      -&gt;range(0, 25);
    $result = $entity_query-&gt;execute();
    if (isset($result['node'])) {
      node_delete_multiple(array_keys($result['node']));
    }
  }


Using hook_cron() avoids issues in the case there are many nodes to delete. Trying to load, for example, 3000 nodes (even if the EntityFieldQuery class returns partially loaded nodes) could cause memory or timeout errors.