You've already forked crontab-ui
mirror of
https://github.com/alseambusher/crontab-ui.git
synced 2025-12-15 11:43:58 +08:00
reading crontab from db done
This commit is contained in:
29
crontab.js
Normal file
29
crontab.js
Normal file
@@ -0,0 +1,29 @@
|
||||
//load database
|
||||
var Datastore = require('nedb');
|
||||
var db = new Datastore({ filename: __dirname + '/crontabs/crontab.db' });
|
||||
db.loadDatabase(function (err) {
|
||||
});
|
||||
|
||||
crontab = function(command, schedule, stopped){
|
||||
var data = {};
|
||||
data.command = command;
|
||||
data.schedule = schedule;
|
||||
data.stopped = stopped;
|
||||
data.timestamp = (new Date()).toString();
|
||||
return data;
|
||||
}
|
||||
|
||||
exports.create_new = function(command, schedule){
|
||||
var tab = crontab(command, schedule, false);
|
||||
db.insert(tab);
|
||||
}
|
||||
|
||||
exports.crontabs = function(callback){
|
||||
var finished = false;
|
||||
db.find({}, function(err, docs){
|
||||
finished = true;
|
||||
callback(docs);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user