2012-03-25 2 views
0

다음은 내 rc.local 파일의 내용입니다. sudo /etc/rc.local을 실행하면 정상적으로 작동합니다. 내가 부팅 할 때. 나는 monit이 설치되기를 기대하지만 그렇지 않다. 나는 총 손실에 처해있다. 나는 보통 rc.local을 사용하지만 이것은 오히려 혼란 스럽다.ec2의 우분투에서 rc.local이 작동하지 않습니다

#!/bin/sh -e 
# 
# rc.local 
# 
# This script is executed at the end of each multiuser runlevel. 
# Make sure that the script will "exit 0" on success or any other 
# value on error. 
# 
# In order to enable or disable this script just change the execution 
# bits. 
# 
# By default this script does nothing. 

apt-get -y install monit 
/etc/init.d/monit stop 
cd /home/ubuntu/workspace/rtbopsConfig/ 
git fetch 
git checkout origin/master rtb_ec2_boot/ec2_boot.py 
git checkout origin/master config/ 
cp /home/ubuntu/workspace/rtbopsConfig/config/monit/redis/monitrc /etc/monit/ 
/usr/bin/python /home/ubuntu/workspace/rtbopsConfig/rtb_ec2_boot/ec2_boot.py >> /home/ubuntu/workspace/ec2_boot.txt 2>&1 

/etc/init.d/monit start 
chkconfig monit on 

exit 0 

답변

4

당신이 스크립트를 시작할 수 있습니다

apt-get update 

당신의 APT 캐시는 "apt-get을 설치"에 대한 최신이 될 수있다.

또한이 두 라인을 시작하여 스크립트를 디버깅 할 수 있습니다 : 당신이 알 수 있도록 /var/log/rc.local.log하는

#!/bin/bash -ex 
exec > >(tee /var/log/rc.local.log|logger -t rc.local -s 2>/dev/console) 2>&1 

이 각 명령 에코하고 출력 무엇 실패하고 어떤 오류가 있습니다.

파일이 실행되어 있는지 확인하십시오 : rc.local 파일이 에있는 모든 부팅뿐만 아니라 첫 번째 부팅을 실행하는 것을

sudo chmod 755 /etc/rc.local 

참고. 시스템이 잠시 작동하면 다시 실행되는지 확인하십시오.

가 여기에 위의 "간부"명령에 대한 자세한 정보와 함께 쓴 기사입니다 : 내 경우 http://alestic.com/2010/12/ec2-user-data-output

+0

감사합니다. 나는 노력했지만 여전히 쓸모가 없다. 이것은 다소 이상합니다. – Tampa

+0

두 줄로 rc.local을 시작하고 재부팅 할 때 일어나는 일에 대해 더 자세히 알려주십시오. /var/log/rc.local.log 파일이 생성 되었습니까? 무엇이 포함되어 있습니까? –

+1

나는 동일한 행동을 발견했습니다. 재부팅 후에 /etc/rc.local가 호출되지 않습니다. – mark

0

, 실수로 rc.local에 내 CRLF line endings을 사용했다. 그것들을 LF 엔딩으로 변환 한 후, 내 rc.local이 마침내 실행되었습니다.

잘못된

#!/bin/sh\r\n 
#\r\n 
# This script will be executed *after* all the other init scripts.\r\n 
# You can put your own initialization stuff in here if you don't 
# want to do the full Sys V style init stuff.\r\n 
\r\n 
touch /var/lock/subsys/local\r\n 

올바른

#!/bin/sh\n 
... 
관련 문제