首先创建服务文件
vim /etc/systemd/system/node.service
#内容如下
[Unit]
Description=ethereum-go Monitor Daemon
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/monitors/XXX
ExecStart=/bin/sh -c '/usr/bin/geth -fast -rpc -rpccorsdomain * -rpcaddr 0.0.0.0 2>> /var/log/XXX.log'
Restart=always
[Install]
WantedBy=multi-user.target
- User填写需要以哪个用户启动服务
- ExecStart 填写要执行的命令
重载配置
systemctl daemon-reload
然后启动服务
systemctl start node
systemctl stop node
开机启动、关闭
systemctl enable node
systemctl disable node
编写语法参考