两个简单的python文件,实现删除本地文件夹和mongodb数据库的内容

删除本地文件夹:

import os , string , datetime ;
str = '/home/aaa/tmp/tomcat/';
b = (datetime.datetime.now()).second + 5;
while 1 :
a = datetime.datetime.now();
if a.second == b :
files = os.listdir(str);
for file in files :
os.remove(str+file);
b = (a + datetime.timedelta(seconds=5)).second;

删除mongodb数据库:

import os , string , datetime , pymongo;

conn = pymongo.Connection("127.0.0.1",27017);
db = conn.nn;
coll = db.nn_res;
b = (datetime.datetime.now()).second + 5;
while 1:
a = datetime.datetime.now();
if a.second == b :
curr = coll.find().sort("update_time",1).limit(1);
for tmp in curr :
coll.remove(tmp);
b = (a + datetime.timedelta(seconds=5)).second;
上一篇:res文件夹及xml资源文件详解


下一篇:MFC下debug改成release版本出现问题及解决办法