Ubuntu设置trojan每日零点重启
下载安装cron
1apt-get install cron
查看cron状态
1systemctl status cron
编辑cron文件
1nano /etc/crontab
2# 添加Trojan每日零点重启任务
3# F2保存 F3退出
/etc/crontab文件内容
1# /etc/crontab: system-wide crontab
2# Unlike any other crontab you don't have to run the `crontab'
3# command to install the new version when you edit this file
4# and files in /etc/cron.d. These files also have username fields,
5# that none of the other crontabs do.
6
7SHELL=/bin/sh
8PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
9
10# Example of job definition:
11# .---------------- minute (0 - 59)
12# | .------------- hour (0 - 23)
13# | | .---------- day of month (1 - 31)
14# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
15# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
16# | | | | |
17# * * * * * user-name command to be executed
18 17 * * * * root cd / && run-parts --report /etc/cron.hourly
19 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
20 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
21 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
22#
23
24
25# 每天零点重启Trojan
26 0 0 * * * root service trojan restart
设置好重启cron
1systemctl restart cron