私は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コマンドを実行すると、操作は期待通りに開始されます。マシンを起動するたびにこのコマンドを実行するにはどうすればよいですか?
あなたはrootユーザーとして「cd/home/ubunto/somefolderに直接cdしてセロリコマンドを実行しましたか? –
つまり$ sudoセロリ...?私はそれを試していませんが、これが許可の意味を理解しています。 – user714852
、さらには 'sudo su -'、次にcd ...そしてセロリー...許可問題が既にディレクトリに影響する場合は –