开发者

database query filling the var/temp

I am not a programmer so please be gentle :)

Following query on our website loads a lot of data to server's var/temp folder and creates server load and all sorts of troubles.

{php}
global $db;


$res = $db->get_results("select * from ".table_links." , pligg_files where      link_status='queued' and file_link_id = link_id and  file_size = '85x85' ORDER BY   `link_date` DESC LIMIT  5");

echo "<ul class='upcomstory'>";
foreach($res as $rslink)
{

$rslink->link_title = utf8_substr($rslink->link_title, 0, 40) . '...';

$cat = $db->get_var("select category_name from ".table_categories." where category__auto_id='".$rslink->link_category."'");
$catvar = $db->get_var("select category_safe_name from ".table_categories." where category__auto_id='".$rslink->link_category."'");
//echo "<li><div class='stcon'><div class='stpic'><img class='stimg' alt='".$rslink->link_title."' src='".my_base_url.my_pligg_base."/modules/upload/attachments/thumbs/".$rslink->file_name."' /&开发者_如何学运维gt;</div><a href='".my_base_url.my_pligg_base."/story.php?id=".$rslink->link_id."'>".$rslink->link_title."</a><br /><br /> <span style='color:#044B9B;font-weight:bold;'>".$rslink->link_votes."</span> Vote -In: <span style='font-weight:bold;color:#044B9B;'>".$cat."</span></div> </li>";
echo '<li><div class="stcon"><div class="stpic"><img class="stimg" alt="'.$rslink->link_title.'" src="'.my_base_url.my_pligg_base.'/modules/upload/attachments/thumbs/'.$rslink->file_name.'" /></div><a href="'.my_base_url.my_pligg_base.'/story.php?id='.$rslink->link_id.'">'.$rslink->link_title.'</a><br /><br /> <span style="color:#044B9B;font-weight:bold;">'.$rslink->link_votes.'</span> Vote(s) </div> </li>';

}

echo "</ul>";
{/php}

Is there a way to 'clear' the output automatically as part of this query once every few minutes?

Thanks


It's not really clear how this could be filling your directory. But, you could use a cron job to periodically clean out that folder. This will delete any files that are older than 60 minues.

@hourly find /var/temp/ -mmin +60 -exec rm {} \;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜