Add custom taxonomy for post using cron job

The problem is that there may not be a current user when that cron job runs. so you need to check if there is a logged in user, save their ID if so, then set the current user to whatever ID has the correct capabilities, do your stuff, then set it back to whatever it was before. Something like this (untested code, don’t throw this anywhere important without testing it)

$old_user = get_current_user_id();
wp_set_current_user(1); //use whatever ID you want here
    //do your stuff
$post_location = array_map('intval', $post_location);
if ($post_type == 'post') {
    $post_arr['tax_input'] = $post_location;
}
wp_set_current_user($old_user);