在suse 10中,将在系统启动时需要启动的脚本链接到相应的启动级别/etc/init.d/rc?.d目录下,以S开头的脚本就会在系统启动时执行。
在suse 12中,则是将需要启动的脚本写入/etc/init.d/after.local文件中,建议在启动脚本中定义好执行脚本的shell程序,否则应如下面的例子中所示加上#!/bin/bash语句以指定shell,避免出现执行失败的错误(失败案例)。
cat /etc/init.d/after.local #!/bin/bash date >> /var/log/osboot.log
注:redhat 7中的启动脚本放置文件则是/etc/rc.d/rc.local,并且需要使用命令“chmod +x /etc/rc.d/rc.local”让文件具有可执行权限。
在suse 15中,以上方法都失效了,需要将启动脚本配置成跟系统的服务一样,通过systemctl命令来控制命令的启用和禁用。配置方法是在/usr/lib/systemd/system目录下,配置好服务的配置文件servicename.service,在其中定义服务的启动停止脚本,然后在/etc/systemd/system建立一个指向/usr/lib/systemd/system目录下服务配置文件的软链接,再enable服务即可。
#请将以下示例中的servicename更改为实际的服务名称 cd /usr/lib/systemd/system #建立服务配置文件 vi servicename.service [Unit] Description=ServiceName Startup and Shutdown Service After=network.target [Service] Type=simple RemainAfterExit=yes ExecStart=/bin/bash /servicedirectory/start_service.sh ExecStop=/bin/bash /servicedirectory/stop_service.sh TimeoutStartSec=1min TimeoutStopSec=1min TimeoutStartFailureMode=abort TimeoutStopFailureMode=abort [Install] WantedBy=multi-user.target #建立软链接 ln -s /usr/lib/systemd/system/servicename.service /etc/systemd/system/servicename.service #启用服务 systemctl enable servicename.service systemctl is-enabled servicename.service
可以参考SAP HANA服务配置方法。



