Last active
October 18, 2016 09:36
-
-
Save bilashcse/5b970e74843edd6004bfb10040a089b9 to your computer and use it in GitHub Desktop.
A Node.js script to remove all images of a directory which are more then 6 hours older using NodeJs child process
This file contains 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 CronJob = require('cron').CronJob; | |
var exec = require('child_process').exec; | |
var path = '../tmp/uploads'; | |
var job = new CronJob({ | |
cronTime: '*/59 * * * *', | |
onTick: function() { | |
exec('find '+path+' -mmin +359 -type f -name "*.*" -exec rm -f {} +', function(err,stdout,stderr){ | |
if(err) | |
console.log(err); | |
}); | |
}, | |
start: false, | |
timeZone: 'Asia/Dhaka' | |
}); | |
job.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment