The following piece of code will update a field of a specific content type by SQL and it is written in a custom module with hook_cron(). Since it updates the database table directly so you have to use it with extreme caution.
function <MODULE>_cron() {
// Get the list of node ids
$sql = "SELECT nid FROM {node} WHERE type = :type";
$result = db_query($sql, array(':type' => '<TYPE>'));
$nids = array();
foreach ($result as $row) {
$nids[] = $row->nid;
}
// Update the table directly
db_update('<FIELD TABLE NAME>')
->fields(array('<FIELD NAME>' => '<NEW VALUE>'))
->condition('entity_id', $nids)
->execute();
// Clear the cache
drupal_flush_all_caches();
}
Done =)
Pingback: Drupal 7 – Use queues for long running tasks in cron | Eureka!