npm install chronosAfter you got nodejs (which includes npm now), you can just:
npm install -g chronos
And that's it.
chronos should be compatible with every service that supports AMQP. You can configure chronos by placing a JSON file in /etc/chronos.json or /usr/local/etc/chronos.json. Example:
{
"amqp" : {
"host" : "10.0.13.1",
"port" : 5672,
"login" : "guest",
"password" : "guest",
"vhost" : "/",
"key" : "somekey"
},
"stage" : "production"
}
If you don't set one of those, the defaults apply:
{
"amqp" : {
"host" : "127.0.0.1",
"port" : 5672,
"login" : "guest",
"password" : "guest",
"vhost" : "/",
"key" : "logging"
},
"stage" : false
}
Let's say your current crontab looks something like this:
0 date >> /var/log/cronjobs/myjob.log && php /var/www/myapp/cli/index.php --some=bar
If you just replace this by:
0 chronos -s mystage -j myjob 'php /var/www/myapp/cli/index.php --some=bar'
From now on chronos will log the results of your cronjobs to graylog2.
The cli options of chronos are:
jobname:* (-j, required) Name of the cronjob, any string will do.
stage:* (-s) Define a stage, if none is given the one in /etc/chronos.json is added
stdout:* (-o) Add stdout output to log
stderr:* (-e) Add stderr output to log
env:* (-v) Add all environment variables to the log
chronos -oj job1 'printf "This output will be added to the log"'
chronos -j job2 'printf "This will trigger an Error-level message"; exit 1;'