编写shell脚本
#!/bin/bash
su -dmdba >>EOF
cd /home/dmdba/dmdbms/bin
./DmServiceDMTEST start
echo "dm start ... "
EOF
 
注意:DmServiceDMTEST每个服务器设置的不一样,根据实际进行更换
授权脚本可执行权限
chmod -x /dmdata/dmserver.sh
 
配置systemd服务
vim /etc/systemd/system/dmserverstart.service
 
[Unit]
Description=The DM8 auto run when reboot
After=default.target
[Service]
ExecStart=/dmdata/dmserver.sh
[Install]
WantedBy=default.target
 
将dmserverstart.service设置到开机启动服务中
systemctl daemon-reload
systemctl enable dmserverstart.service
 
如图中
 
 重启服务器
reboot
 
查看是否启动成功:
ps aux|grep dmdba
 

 图中表示启动成功


















