autosave mode

This commit is contained in:
alseambusher
2016-12-03 21:09:12 +05:30
parent f2987e7ee4
commit 65acd94271
4 changed files with 48 additions and 11 deletions

View File

@@ -1,3 +1,4 @@
/*jshint esversion: 6*/
//load database
var Datastore = require('nedb');
var db = new Datastore({ filename: __dirname + '/crontabs/crontab.db' });
@@ -68,7 +69,6 @@ exports.set_crontab = function(env_vars, callback){
log_file = exports.log_folder + "/" + tab._id + ".log";
if(tab.command[tab.command.length-1] != ";") // add semicolon
tab.command +=";";
//{ command; } 2>/tmp/<id>.log|| {if test -f /tmp/<id>; then date >> <log file>; cat /tmp/<id>.log >> <log file>; rm /tmp<id>.log }
crontab_string += tab.schedule + " { " + tab.command + " } 2> " + tmp_log +"; if test -f " + tmp_log +"; then date >> " + log_file + "; cat " + tmp_log + " >> " + log_file + "; rm " + tmp_log + "; fi \n";
}
else {
@@ -129,7 +129,7 @@ exports.restore = function(db_name){
db.loadDatabase(); // reload the database
};
exports.reload_db= function(){
exports.reload_db = function(){
db.loadDatabase();
};
@@ -170,3 +170,8 @@ exports.import_crontab = function(){
});
});
};
exports.autosave_crontab = function(callback) {
let env_vars = exports.get_env();
exports.set_crontab(env_vars, callback);
};