Created
June 15, 2018 06:49
-
-
Save mohierf/661fe8f8bf68e980198da305da07aed3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var date = new Date(); | |
var daysToDeletion = 120; | |
var deletionDate = new Date(date.setDate(date.getDate() - daysToDeletion)); | |
printjson(deletionDate); | |
var db = db.getSiblingDB('alignak-backend') | |
db.getMongo().setSlaveOk(); | |
// logcheckresult and/or history are candidates to deletion | |
printjson(db.logcheckresult.find({insertDate : {$lt : deletionDate}}).count()); | |
//delete old logcheckresult: | |
db.logcheckresult.remove({insertDate : {$lt : deletionDate}}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment