2016-07-23 5 views
6

console output에 대한 업 스타트의 예제를 사용했습니다.업 스타트 콘솔 출력이 작동하지 않습니다.

/etc/init/test.conf

console output 

pre-start script 

    # Perform whatever checks you like here (maybe checking 
    # '/etc/default/foo' to see if the service is enabled # or not). 
    # 
    # if there are no problems detected, simply "exit 0", else do 
    # something like this... 

    # display an error message to stderr *on the console* and also write 
    # the same message to the system log. 
    logger -is -t "$UPSTART_JOB" "ERROR: foo!" 

    # tell Upstart not to start the main process for the job. 
    exit 1 
end script 

# this service doesn't do much :-) 
exec sleep 999 

그리고 루트

$ initctl start test 
initctl: Job failed to start 

과 같은 메시지가 /var/log/syslog에 존재하지만 메시지가 콘솔에 존재하지 않았다.

Jul 23 07:42:19 paul test[26595]: ERROR: foo! 

어떻게 콘솔에 오류를 기록 할 수 있습니까?

이 우분투 14.04입니다

,

$ initctl version 
init (upstart 1.12.1) 

답변

3

console output는 기본적으로 시스템의 가상 로깅 장치 /dev/console에 기록 : 개인 콘솔 (예를 들어, /dev/tty0)에 기록 않을거야.

당신이이 가상 장치에 직접 작성하려고하면 당신은 실제로 행동의 차이를 테스트 할 수 있습니다

sudo echo test >> /dev/console  # Won't work 
sudo su; echo test >> /dev/console # Works but nothing prints 
sudo echo test >> /dev/tty0  # Works and prints 

다른 가상 콘솔 장치의 차이점에 대한 자세한 내용은 this Unix StackExchange question를 참조하십시오.

당신이 정말로 원하는 경우, 당신은 당신의 부팅 구성 수정하여 무엇 /dev/console 포인트를 변경할 수 있습니다

# /etc/default/grub 

# If you change this file, run 'update-grub' afterwards to update 
# /boot/grub/grub.cfg. 

GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8" 

을 ...하지만 내가 당신이라면, 난 그냥 console log 스탠자를 사용하는 대신 console output 및 것 그런 다음 생성 된 파일을 꼬리십시오.

+0

그래서''콘솔에 stderr *에 오류 메시지를 표시합니다. '라고 말하면,''오류 메시지를 sysadmin의 콘솔에 stderr에 표시 하시겠습니까?'? 나는 그것의 유용성이 무엇인지 확신하지 못한다. –

+0

sysadmin의 콘솔 일 수도 있고 아닐 수도있는'/ dev/console'을 설정 한 콘솔이 될 것입니다.하지만 이것은 매우 합당한 기본 설정입니다. 열린 상태에서 시스템 프로세스를 로깅하는 데 보안상의 영향이 있습니다 . – fny