vim /usr/lib/systemd/system/openoffice.service

[Unit]
#服务描述
Description=OpenOffice
#指定了在systemd在执行完那些target之后再启动该服务
After=network.target

[Service]
#定义Service的运行类型
User=root
Group=root

Type=simple


#定义systemctl start|stop|reload *.service 的执行方法(具体命令需要写绝对路径)
#注:ExecStartPre为启动前执行的命令
ExecStart=/opt/openoffice4/program/soffice.bin -headless -accept=socket,host=127.0.0.1,port=18101;urp; -nofirststartwizard
Restart=always
#创建私有的内存临时空间
PrivateTmp=True

[Install]
#多用户
WantedBy=multi-user.target

错误处理

如果报错 no suitable windowing system found
则需要安装

yum groupinstall "X Window System"