## USAGE # --- 配置自启 echo "RUN: $(date)" \ && username="user" \ && servername="yancheng" \ && filepath="/usr/lib/systemd/system/${servername}.service" \ && projectdir="/home/${username}/repositories/repositories/sri-project.yancheng.master/yancheng-edge" \ && sudo rm -rf ${filepath} \ && sudo touch ${filepath} \ && sudo chmod 777 ${filepath} \ && sudo chmod 777 ${projectdir}/run.sh \ && text=' [Unit] Description={{servername}} Auto-start Service After=network.target [Service] Type=exec WorkingDirectory={{projectdir}} ExecStart=/bin/bash -c "./run.sh" Restart=always User={{username}} Group={{username}} [Install] WantedBy=multi-user.target ' \ && sudo echo "${text}" | sudo tee ${filepath} \ && sudo sed -i '1d' ${filepath} \ && sudo sed -i "s|{{username}}|${username}|g" ${filepath} \ && sudo sed -i "s|{{servername}}|${servername}|g" ${filepath} \ && sudo sed -i "s|{{projectdir}}|${projectdir}|g" ${filepath} \ && sudo systemctl daemon-reload \ && sudo systemctl start yancheng.service \ && sudo systemctl enable yancheng.service \ && echo "END: $(date)" # --- 自启服务操作 sudo systemctl list-units --type=service | grep yancheng sudo systemctl status yancheng.service sudo systemctl stop yancheng.service sudo systemctl start yancheng.service sudo systemctl restart yancheng.service sudo systemctl enable yancheng.service sudo journalctl -u yancheng.service -f