赞
踩
vim /etc/systemd/system/rc-local.service
文件内容:
- [Unit]
- Description=/etc/rc.local Compatibility
- ConditionPathExists=/etc/rc.local
-
- [Service]
- Type=forking
- ExecStart=/etc/rc.local start
- TimeoutSec=0
- StandardOutput=tty
- RemainAfterExit=yes
- SysVStartPriority=99
-
- [Install]
- WantedBy=multi-user.target
vim /etc/rc.local
文件内容:
- #!/bin/bash -e
-
- # source /root/anaconda3/bin/activate flask_test
- # source命令进行conda环境激活,需要使用绝对路径打开acvatie目录指定。
-
- cd /root/flask_test
- gunicorn -w 4 -b 127.0.0.1:8000 flask_test:app &
-
- exit 0
chmod 777 /etc/rc.local
vim /etc/rc.local
文件内容:
- #!/bin/bash -e
-
- bash /root/flask_test/flask_test.sh
-
- exit 0
vim /root/flask_test/flask_test.sh
文件内容:
- #!/bin/bash
-
- cd /root/flask_test
- gunicorn -w 4 -b 127.0.0.1:8000 flask_test:app &
- chmod 777 /etc/rc.local
- chmod 777 /root/flask_test/flask_test.sh
systemctl enable rc-local.service
systemctl start rc-local.service
systemctl status rc-local.service
成功状态:
如需停止服务:
systemctl stop rc-local.service
设置开机自启同时立即启动:
systemctl enable --now rc-local.service
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。