mirror of
https://gitee.com/callmer/pve_toss_notes.git
synced 2026-09-01 14:32:53 +08:00
更新 Cronie 定时任务配置方法
This commit is contained in:
+22
-28
@@ -158,21 +158,16 @@ $ sudo snap set system refresh.timer=mon,2:30,,fri,2:30
|
||||
|
||||
本步骤为可选操作,主要用于设置 `Adguard Home` 定时重启。
|
||||
|
||||
```bash
|
||||
## 查看系统定时任务
|
||||
$ sudo crontab -l
|
||||
|
||||
## 编辑系统定时任务,编辑器选择 nano
|
||||
$ sudo crontab -e
|
||||
```
|
||||
|
||||
在配置文件末尾,增加以下内容。
|
||||
执行以下命令创建 Cronie 系统定时任务文件。
|
||||
|
||||
```bash
|
||||
## 定时任务配置项
|
||||
|
||||
30 4 * * * /usr/bin/snap restart adguard-home
|
||||
## 创建 Adguard Home 定时重启任务
|
||||
$ sudo tee /etc/cron.d/adguard-home-restart >/dev/null <<'EOF'
|
||||
30 4 * * * root /usr/bin/snap restart adguard-home
|
||||
EOF
|
||||
|
||||
## 设置定时任务文件权限
|
||||
$ sudo chmod 0644 /etc/cron.d/adguard-home-restart
|
||||
```
|
||||
|
||||
## 6. SmartDNS
|
||||
@@ -264,31 +259,30 @@ $ sudo /usr/local/bin/smartdns-cnlist
|
||||
|
||||
本步骤为可选操作,主要用于设置 `SmartDNS` 定时更新附加配置文件和定时重启。
|
||||
|
||||
```bash
|
||||
## 编辑系统定时任务,编辑器选择 nano
|
||||
$ sudo crontab -e
|
||||
```
|
||||
|
||||
若使用了 `SmartDNS` 加速规则的安装脚本,由于脚本自带服务重启功能,因此定时任务可设置如下。
|
||||
|
||||
```bash
|
||||
## 定时任务配置项
|
||||
|
||||
20 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/anti-ad.smartdns.conf https://anti-ad.net/anti-ad-for-smartdns.conf
|
||||
|
||||
30 9 * * * /usr/local/bin/smartdns-cnlist
|
||||
## 创建 SmartDNS 规则更新任务
|
||||
$ sudo tee /etc/cron.d/smartdns-rules-update >/dev/null <<'EOF'
|
||||
20 9 * * * root /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/anti-ad.smartdns.conf https://anti-ad.net/anti-ad-for-smartdns.conf
|
||||
30 9 * * * root /usr/local/bin/smartdns-cnlist
|
||||
EOF
|
||||
|
||||
## 设置定时任务文件权限
|
||||
$ sudo chmod 0644 /etc/cron.d/smartdns-rules-update
|
||||
```
|
||||
|
||||
若仅需定时重启 `SmartDNS` 服务,定时任务可调整如下。
|
||||
若仅需定时重启 `SmartDNS` 服务,可使用以下命令覆盖该定时任务文件。
|
||||
|
||||
```bash
|
||||
## 定时任务配置项
|
||||
|
||||
20 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/anti-ad.smartdns.conf https://anti-ad.net/anti-ad-for-smartdns.conf
|
||||
|
||||
30 9 * * * /usr/bin/systemctl restart smartdns.service
|
||||
## 创建 SmartDNS 规则更新任务
|
||||
$ sudo tee /etc/cron.d/smartdns-rules-update >/dev/null <<'EOF'
|
||||
20 9 * * * root /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/anti-ad.smartdns.conf https://anti-ad.net/anti-ad-for-smartdns.conf
|
||||
30 9 * * * root /usr/bin/systemctl restart smartdns.service
|
||||
EOF
|
||||
|
||||
## 设置定时任务文件权限
|
||||
$ sudo chmod 0644 /etc/cron.d/smartdns-rules-update
|
||||
```
|
||||
|
||||
### 6.3. SmartDNS 主配置
|
||||
|
||||
Reference in New Issue
Block a user