我已經在Ubuntu系統上安裝了一個關閉腳本,它沒有被執行。它是一個Amazon EC2實例。我不確定它只是想指出這一點。爲什麼關機腳本不能運行?
該腳本應將一些日誌文件推送到Amazon S3存儲桶,以便在網絡連接啓動時執行。
這裏是我安裝的腳本:在/etc/init.d/push-apache-logs-to-s3.sh
與所需的命令
1)創建的文件。
2)製成它可執行與執行的sudo chmod +x push-apache-logs-to-s3.sh
3)sudo update-rc.d push-apache-logs-to-s3.sh start 0 0 .
從上述
輸出是:
update-rc.d: warning: /etc/init.d/push-apache-logs-to-s3.sh missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
Adding system startup for /etc/init.d/push-apache-logs-to-s3.sh ...
/etc/rc0.d/S00push-apache-logs-to-s3.sh -> ../init.d/push-apache-logs-to-s3.sh
的/etc/rc0.d/
內容現在是:
lrwxrwxrwx 1 root root 17 Jul 31 2012 K09apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 29 Jun 16 2012 K10unattended-upgrades -> ../init.d/unattended-upgrades
lrwxrwxrwx 1 root root 26 Jun 16 2012 K15landscape-client -> ../init.d/landscape-client
lrwxrwxrwx 1 root root 19 Apr 10 11:11 K20memcached -> ../init.d/memcached
-rw-r--r-- 1 root root 353 Jul 26 2012 README
lrwxrwxrwx 1 root root 35 Jul 10 12:01 S00push-apache-logs-to-s3.sh -> ../init.d/push-apache-logs-to-s3.sh
lrwxrwxrwx 1 root root 18 Jun 16 2012 S20sendsigs -> ../init.d/sendsigs
lrwxrwxrwx 1 root root 17 Jun 16 2012 S30urandom -> ../init.d/urandom
lrwxrwxrwx 1 root root 22 Jun 16 2012 S31umountnfs.sh -> ../init.d/umountnfs.sh
lrwxrwxrwx 1 root root 20 Jun 16 2012 S35networking -> ../init.d/networking
lrwxrwxrwx 1 root root 18 Jun 16 2012 S40umountfs -> ../init.d/umountfs
lrwxrwxrwx 1 root root 20 Jun 16 2012 S60umountroot -> ../init.d/umountroot
lrwxrwxrwx 1 root root 14 Jun 16 2012 S90halt -> ../init.d/halt
當我手動執行與sudo ./push-apache-logs-to-s3.sh
腳本,它的目標工作。
這些腳本是由root
執行的嗎?我錯過了什麼?
需要多長時間才能運行?如果實例處於關閉狀態,但時間過長,則ec2將通過終止將其清除。您應該嘗試將腳本直接放入rc0.d中,因爲它不是普通的服務控制腳本。 – datasage
你是否正在用shutdown/halt關閉實例,還是使用ec2 terminate/stop關閉它? –
也是你暫停它(0)或告訴它重新啓動(6)。 ? – Doon