diff --git a/www/create.php b/www/create.php
index 37e2f8b..54021a0 100755
--- a/www/create.php
+++ b/www/create.php
@@ -13,6 +13,7 @@ if(empty($id)) {
Goto http://$HTTP_HO
echo "Goto http://$id.$HTTP_HOST to grep!
";
}
-echo `sed -e "s,TIMESTAMP,$(date)," ../../greptweet.appcache > greptweet.appcache`;
-
$logfile = "fetch-" . time() . ".log";
-exec(sprintf("../../fetch-tweets.sh %s > %s 2>&1 &", $id, $logfile));
+
+// Only update Appcache file once we are done with the fetch
+exec(sprintf("../../fetch-tweets.sh %s > %s 2>&1 && sed -e 's,TIMESTAMP,%s,' ../../greptweet.appcache > greptweet.appcache &", $id, $logfile, date("c")));
+
+// Remove logs older than a day
+`find -name '*.log' -mtime +1 -exec rm {} \; &`;
+
?>
Fetching tweets can take time! And it's limited by Twitter to 3200 maximum at any one time. Please view the >logfile to see its progress.