Node PHP function causing CRON not to run properly
Try debug_cron module to debug the cron issue.Also I am not sure if the mentioned code is even executing on cron run.
This module provides debugging of

 fail due to programming or runtime errors
 time out (PHP, server, database)
 are very slow



  Cron Debug will also allow you to test run specific cron functions
  while not running others. This can be nice for developing cron
  functions where you don't want to run a full cron.php with all
  maintenance, alerts and other tasks every time you test your own
  function.


Also why not you putting the complete code inside the first if conditions like'

if ($node = menu_get_object()) {  
  $nid = $node-&gt;nid; 
  $staticPath = file_create_url($node-&gt;field_static_ad['und'][0]['uri']); 
  $flashPath = field_get_items('node', $node, 'field_flash_ad'); 
  if ($flashPath) {
    $flashPath = file_create_url($node-&gt;field_flash_ad['und'][0]['uri']); 
  } else {
      $flashPath = file_create_url($node-&gt;field_static_ad['und'][0]['uri']);
   }
}