/etc/rc.local
- 开机启动程序,把需要开机自动运行的程序写在这个脚本里
/etc/init.d
- 这个目录存放的是一些脚本,一般是linux以rpm包安装时设定的一些服务的启动脚本。
- 要重新启动 sendmail 的话,而且你的 sendmail 是以 rpm 来安装的。rpm
- /etc/rc.d/init.d/sendmail restart 就可以直接启动 sendmail
Fedora或者Ubuntu系统中的 /etc/rc.d/init.d 目录。实际上无论init.d放在什么地方,它都发挥着相同的作用。
方法1、添加到开机启动项里面
开机自动重启脚本简介
经常碰到机器断电之后需要重启一大堆服务,为了防止这种事情发生,设置开机自启的脚本十分的重要,我们习惯性的做法就是编写一个重启脚本,然后在 /etc/rc.local 中去完成开机执行。例如下面这样:
# chmod +x /etc/rc.local # 确保/etc/rc.local,有权限去执行命令
# vi /etc/rc.local
/usr/local/nginx/sbin/nginx
service start tomcat
/usr/local/apache/bin/apachectl start
service mysql star
cd /opt/ && ./start.sh
/home/www/guonei_netprotect.sh