debian service
- Category: 電腦相關
- Last Updated: Tuesday, 18 November 2014 09:12
- Published: Tuesday, 18 November 2014 09:12
- Written by sam
在debian開機時能執行script
debian似乎不像redhat系列能直接加在rc.d裡面(但也可以弄在rcS.d)
所以就比較麻煩一點點
先寫下需要的指令
#!/bin/bash ### BEGIN INIT INFO # Provides: sam # Required-Start: $remote_fs $samnfs # Required-Stop: $remote_fs $samnfs # Should-Start: $network $time # Should-Stop: $network $time # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: auto mount nfs # Description: auto mount nfs ### END INIT INFO mount 192.168.1.3:/volume1/git /mnt/git
標頭要記得上…並視需要修改
可見到其實只有一行指令 (開機掛載遠端的nfs目錄過來)
然後將之放到
/etc/init.d/mountnfssam
記得加上執行的權限 使用chmod +x
再來使用
sudo update-rc.d mountnfssam defaults
這樣就行了
最後一樣是要檢查
看看是否都有正確的出現在每個資料夾
ls -l /etc/rc*.d/*mountnfssam lrwxrwxrwx 1 root root 21 Nov 18 08:58 /etc/rc0.d/K01mountnfssam -> ../init.d/mountnfssam lrwxrwxrwx 1 root root 21 Nov 18 08:58 /etc/rc1.d/K01mountnfssam -> ../init.d/mountnfssam lrwxrwxrwx 1 root root 21 Nov 18 08:58 /etc/rc2.d/S16mountnfssam -> ../init.d/mountnfssam lrwxrwxrwx 1 root root 21 Nov 18 08:58 /etc/rc3.d/S16mountnfssam -> ../init.d/mountnfssam lrwxrwxrwx 1 root root 21 Nov 18 08:58 /etc/rc4.d/S16mountnfssam -> ../init.d/mountnfssam lrwxrwxrwx 1 root root 21 Nov 18 08:58 /etc/rc5.d/S16mountnfssam -> ../init.d/mountnfssam lrwxrwxrwx 1 root root 21 Nov 18 08:58 /etc/rc6.d/K01mountnfssam -> ../init.d/mountnfssam
如此.大致就是成功了