Вопрос

I'm using upstart on Ubuntu to manage services. It writes to /var/log/upstart/<service>.log. Errors in this file don't have timestamps, which makes it difficult to diagnose problems.

Is there a way -- a stanza of some kind in the config file -- to tell upstart to write timestamps with its log output?

Это было полезно?

Решение 2

There may be a much more elegant way to do what you want, but I've found the following ghetto method to be sufficiently effective :

           echo "`date` : Doing the next thing..."

Другие советы

You can try using annotate-output shell script from the devscripts package:

Source code here.

Your service should maintain the dates/timing... The logs which appear in the logs under /var/log/upstart/ are the output of your upstart script .

Also you can add a pre-start and a pre-stop section into your conf file, to print the time before the service is ran and the timing after the service has stopped:

pre-start script
    echo "[`date`] <YOUR SERVICE NAME> Starting" >> /var/log/<YOUR SERVICE NAME>.log
end script

pre-stop script
    echo "[`date`] <YOUR SERVICE NAME> Stopping" >> /var/log/<YOUR SERVICE NAME>.log
end script
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top