一、編輯文件 /etc/rc.local
vim /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
#在文件末尾(exit 0以前)加上你開機須要啓動的程序或執行的命令便可(執行的程序須要寫絕對路徑,添加到系統環境變量的除外),如
/usr/local/thttpd/sbin/thttpd -C /usr/local/thttpd/etc/thttpd.conf
二、本身寫一個shell腳本
將寫好的腳本(.sh文件)放到目錄
/etc/profile.d/ 下,系統啓動後就會自動執行該目錄下的全部shell腳本