mongodb定时移除数据


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

需求:定时删除mongodb指定库1个月前的数据
bat文件内容:

@echo off
E:mongodbbinmongo  MyDB -u myuser -p mypassword  -quiet removedata.js

js文件内容:

var date = new Date();
date.setDate(date.getDate()-30);
db.bmdMessage.remove({'senddate' : {$lt:date}});

Write Scripts for the mongo Shell