The script below can be used to clean out those duplicate hosts and can be setup to run from cron daily. The script assumes you run this as the root user and have configured root to run spacecmd without specifying username and password at the command line. This was tested with Satellite 5.6.
#!/usr/bin/perl ### Delete duplicate hosts in Satellite or Spacewalk via Spacecmd ### @duphosts = `spacecmd -q system_list | uniq -d`; foreach $system (@duphosts) { chomp($system); $spacecmd = `spacecmd system_details $system 2>&1 |grep $system |grep =|sed 's/^.*=/=/'`; $spacecmd =~ s/\s+//g; $spacecmd =~ s/=//g; @ids = split(/\,/,$spacecmd); $count=0; foreach $ids (@ids) { chomp($ids); $count++; if ($count > $#ids) { print "Duplicates removed for system: $system\n"; last; } $cmd = `spacecmd -y system_delete $ids`; print "$cmd\n"; sleep (2); } print "Cleanup of $system complete...\n"; } print "Cleanup of Satellite complete!\n";