[tool] Ubuntu 设置开机启动python脚本
前言:
话说我每次设置的服务器,再次开机,ip都会随之改变,固定ip有时候确定不好用。所以为啥不让让每次启动都发送ip给我呢。
步骤:
sudo touch /etc/rc.local
sudo chmod 777 /etc/rc.local
sudo systemctl enable rc-local.service
vim /etc/rc.local
#编写脚本#!/bin/bash -e python3 /home/xxxxx/.pyecho start xx.pyexit 0sudo systemctl start rc-local.service #启动sudo systemctl status rc-local.service #查看
输出 >: start xx.py
sudo systemctl stop rc-local.service #关闭
结论:
再搭配上发送到qq邮件的代码,简直美滋滋。