Identifying tags with no content tagged
I have a similar script that I use, but I run it as a drush scr.  You can adapt it for your needs, perhaps to do this in a hook_cron():

$tags = taxonomy_vocabulary_machine_name_load('tags');

$tids = db_query('
  SELECT DISTINCT t.tid
  FROM {taxonomy_term_data} t
  LEFT JOIN {taxonomy_index} i ON i.tid = t.tid
  WHERE t.vid = :vid
    AND i.tid IS NULL
', array(':vid' =&gt; $tags-&gt;vid))-&gt;fetchCol();

if (!empty($tids)) {
  foreach ($tids as $tid) {
    taxonomy_term_delete($tid);
  }

  watchdog('foo', 'deleted @count orphaned tags', array(
    '@count' =&gt; count($tids),
  ), WATCHDOG_NOTICE);
}


This exact version is untested and a hand-edit from a very specific use-case I have.  Take backups and use at your own risk!

The only problem is that {taxonomy_term_data} doesn't have a created column, so this will immediately delete orphaned terms.  It also doesn't take into term hierarchy, or tags being on entities other than nodes.