debian下設定shell指令碼開機自動啟動
1) 進入init.d初始化指令碼目錄
#切換到root使用者
sudo -s
cd /etc/init.d
2) 建立啟動shell指令碼,安裝nano: apt-get install nano
nano /etc/init.d/footbar
3) 編寫node.js啟動指令碼,以oncedoc啟動指令碼為例
#! /bin/sh
### begin init info
# provides: oncedoc
# required-start: $network $remote_fs $local_fs
# required-stop: $network $remote_fs $local_fs
# default-start: 2 3 4 5
# default-stop: 0 1 6
# short-description: start and stop node
# description: oncedoc
### end init info
web_dir='/var/www/oncedoc'
#location of node you want to use
node_exe=/usr/local/bin/node
start()
stop()
case "$1" in
start)
start
;;stop)
stop
;;restart)
stop
#start
;;*)
echo "usage: /etc/init.d/ourjs "
;;esac
exit 0
4) 設定檔案為可執行指令碼
chmod 755 /etc/init.d/foobar
5) 設定指令碼開機時啟動
update-rc.d foobar defaults
7) 設定指令碼開機時不啟動[可選]
update-rc.d -f foobar remove
8) 重啟測試
reboot
linux 下設定定時任務執行shell指令碼
名稱 crontab 使用許可權 root使用者和crontab檔案的所有者 語法 crontab e username l username r username v username file 說明 crontab 是用來讓使用者在固定時間或固定間隔執行程式之用,換句話說,也就是類似使用者的時程...
linux 下設定定時執行shell指令碼
需求 每十分鐘跑一遍自己寫的某個shell指令碼 vim ect crontab 最後一行新增一句 1 root sh projects updateds.sh tmp svnupdatecrontab 1 root svn update projects ds front trunk tmp sv...
Linux Makefile與shell指令碼區別
在makefile可以呼叫shell指令碼,但是makefile和shell指令碼是不同的。本文試著歸納一下makefile和shell指令碼的不同。1 shell中所有引用以 打頭的變數其後要加 而在makefile中的變數是以 打頭的後加 例項如下 makefile path data subp...