Allows monitoring and creating cronjobs via ssh connection
It is available through npm
$ npm install mycron
var mycron = require('mycron')
// if your computer is trusted by server
var params = {
user: 'username',
host: 'host_url'
}
// or using the more settings
var params = {
user: 'username',
host: 'myremote.com',
password: 'passw0rd',
key: myKeyFileOrBuffer
}
//and get your crons
mycron.getCrons(params, function(crons){
console.log(crons);
//or whatever you want to do
});
The response is an array which contains cronjobs sorted by remaining times to next interval in ascending order
[
{
time: 2017-11-30T00:25:00.000,
job: 'NODE_ENV=prod node $HOME/scripts/test1.js',
remainingTime: 'in a minute'
},
{
time: 2017-11-30T01:30:00.000,
job: 'NODE_ENV=prod node $HOME/scripts/test2.js',
remainingTime: 'in an hour and 6 minutes'
},
{
time: 2017-11-31T06:00:00.000,
job: php $HOME/scripts/test3.php',
remainingTime: 'in a day, 5 hours and 36 minutes'
}
]
error: **error_code**
var mycron = require('mycron')
// if your computer is trusted by server
var params = {
user: 'username',
host: 'host_url'
}
// or using the more settings
var params = {
user: 'username',
host: 'myremote.com',
password: 'passw0rd',
key: myKeyFileOrBuffer
}
// define your cronjob(s) as string
var cronjob = "00 09 * * 1-5 echo hello"
// and add your cronjob(s) to crontab
mycron.addCrons(params, crons, function(res){
console.log(res);
});
cronjob(s) created: 00 09 * * 1-5 echo hello
error: **error_code**
MIT