diff --git a/registry/scripts/clean.sh b/registry/scripts/clean.sh
index a3993cd8170f7b96be2fe372ef4b3b529c865711..151302af8b29303641278f2a57e321e2987a5b1a 100755
--- a/registry/scripts/clean.sh
+++ b/registry/scripts/clean.sh
@@ -20,9 +20,10 @@ conf_dir="/etc/registry"
 conf_file="$conf_dir/hosts"
 while read line
 do
-    if [ "$(echo $line | cut -d ' ' -f 1)" -gt "$(date -d '-6 month' +%Y%m%d)" ]
+    if [ ! -z "$line"] && \
+        [ "$(echo $line | cut -d ' ' -f 1)" -lt "$(date -d '-6 month' +%Y%m%d)" ]
     then
-        LINES="$LINES\n$(date +%Y%m%d) $(echo $line | cut -d ' ' -f 2-)"
+        LINES="$LINES\n$line"
     fi
 done < $conf_file
 echo -e $LINES > $conf_file