ec2의 상자에서 ubunto를 실행하고 있습니다. 나는 기계가 시작 특정 위치에 생성 할 때마다 다음과 같은 명령을 실행하고 싶습니다 : 나는 읽을 linux - rc.local을 사용하여 디렉터리를 변경하고 시작시 명령을 실행하는 방법
sudo nano /etc/rc.local
을 실행하고 파일을 편집 한
celery -A someapp.tasks --concurrency=1 --loglevel=info worker > output.log 2> errors.log
#!/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.
(
cd /home/ubuntu/somefolder/
sh -e -c 'celery -A someapp.tasks worker -Ofair --loglevel=info > output.log > errors.log'
)
exit 0
그러나 서버가 시작되면 명령이 실행되지 않습니다./home/ubunto/somefolder로 직접 cd하고 celery 명령을 실행하면 예상대로 작업이 시작됩니다. 컴퓨터를 시작할 때마다이 명령을 어떻게 실행할 수 있습니까?
이cd /home/ubuntu/somefolder && celery -A someapp.tasks --concurrency=1 --loglevel=info worker >output.log 2> errors.log
루트 사용자로 "/ home/ubunto/somefolder로 직접 cd"하고 celery 명령을 실행 해 보셨습니까? –
즉 $ sudo celery ...? 나는 그것을 시도하지 않았지만 이것의 허가 의미가 이해해야합니다. – user714852
또는'sudo su -', cd ... 그리고 셀러리 ... 권한 문제가 이미 디렉토리에 영향을 미친 경우 –