From 64964778fb00da15482feb3c36614d5ad2c3bc07 Mon Sep 17 00:00:00 2001 From: Kai Hendry Date: Sun, 25 Oct 2015 18:54:37 +0800 Subject: [PATCH] Only update appcache once fetch-tweets.sh is done! (duh) --- www/create.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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)) { Fetching tweets of <?php echo $id; ?> + @@ -36,10 +37,14 @@ echo "

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.