接前文,我家里不是搭建了一个 V2ray 的全局代理么,要是持续运行太久,内存估计会吃不消,所以我在网上找到了一个小脚本,定时重启它。
本脚本必须要系统支持 systemd,我用的是Ubuntu,自带 systemd。
首先使用命令 nano /usr/local/restart 创建一个脚本文件,输入:
nano /usr/local/restart
#!/bin/sh systemctl restart v2ray
再创建一个服务,使用命令 nano /etc/systemd/system/restart.service,输入:
nano /etc/systemd/system/restart.service
[Unit] Description=Restart V2Ray [Service] Type=simple ExecStart=/bin/sh /usr/local/restart
然后再创建一个定时器,使用命令 nano /etc/systemd/system/restart.timer,输入:
nano /etc/systemd/system/restart.timer
[Unit] Description=Retart [Timer] OnBootSec=24h #首次启动后多少小时执行 OnUnitActiveSec=24h #每隔多少小时执行 Unit=restart.service [Install] WantedBy=multi-user.target
最后一步执行以下命令激活这个定时器即可:
systemctl start restart.timer && systemctl enable restart.timer
本文将会教你如何白嫖一年的Trello Gold!
关于本站博客的架构调整
使用 AJAX 技术优化访问速度
自己动手写点代码,解决一个非常规的问题。
给博客新增一个小功能,并且展示 ChatGPT 的强大。
目录
热门标签
更多语言
站点信息