We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
问题:无法在crontab文件中配置自动执行。
crontab内容:
57 23 * * * root /root/CloudFlareCDN/cfst_hosts.sh #==》第一种试验方法 2/* * * * * root /usr/bin/bash /root/CloudFlareCDN/cfst_hosts.sh #=》第二种试验方法。
================================================== /var/log/cron 输出:
.....(略)..... Sep 5 10:48:31 localhost CROND[18200]: (root) CMDOUT (使用前请先阅读:https://github.com/XIU2/CloudflareSpeedTest/issues/42#issuecomment-768273848) Sep 5 10:48:31 localhost CROND[10252]: (root) CMDOUT (使用前请先阅读:https://github.com/XIU2/CloudflareSpeedTest/issues/42#issuecomment-768273848) Sep 5 10:48:31 localhost CROND[2582]: (root) CMDOUT (该脚本的作用为 CloudflareST 测速后获取最快 IP 并替换 Hosts 中的 Cloudflare CDN IP。) Sep 5 10:48:31 localhost CROND[18200]: (root) CMDOUT (第一次使用,请先将 Hosts 中所有 Cloudflare CDN IP 统一改为一个 IP。) Sep 5 10:48:31 localhost CROND[10252]: (root) CMDOUT (第一次使用,请先将 Hosts 中所有 Cloudflare CDN IP 统一改为一个 IP。) Sep 5 10:48:31 localhost CROND[2582]: (root) CMDOUT (使用前请先阅读:https://github.com/XIU2/CloudflareSpeedTest/issues/42#issuecomment-768273848) Sep 5 10:48:31 localhost CROND[18200]: (root) CMDOUT (该 IP 不能是空!) Sep 5 10:48:31 localhost CROND[10252]: (root) CMDOUT (该 IP 不能是空!) Sep 5 10:48:31 localhost CROND[2582]: (root) CMDOUT (第一次使用,请先将 Hosts 中所有 Cloudflare CDN IP 统一改为一个 IP。) Sep 5 10:48:31 localhost CROND[18200]: (root) CMDOUT (该脚本的作用为 CloudflareST 测速后获取最快 IP 并替换 Hosts 中的 Cloudflare CDN IP。) Sep 5 10:48:31 localhost CROND[10252]: (root) CMDOUT (该脚本的作用为 CloudflareST 测速后获取最快 IP 并替换 Hosts 中的 Cloudflare CDN IP。) Sep 5 10:48:31 localhost CROND[2582]: (root) CMDOUT (该 IP 不能是空!) .........(略).............
==================== 目录内容 ===================
-rwxr-xr-x 1 root root 1393 8月 29 08:58 使用+错误+反馈说明.txt -rwxr-xr-x 1 root root 1434 9月 5 11:17 cfst_hosts.sh -rwxr-xr-x 1 root root 5890048 8月 11 10:39 CloudflareST -rw-r--r-- 1 root root 2310007 9月 3 13:56 CloudflareST_linux_amd64.tar.gz -rwxr-xr-x 1 root root 292 8月 29 08:40 ipall.txt -rwxr-xr-x 1 root root 358 4月 9 12:52 ip.txt -rwxr-xr-x 1 root root 890 11月 30 2020 ipv6.txt -rw-r--r-- 1 root root 15 9月 5 11:23 nowip.txt -rw-r--r-- 1 root root 788 9月 5 11:23 result.csv [root@localhost CloudFlareCDN]# more nowip.txt 104.18.138.102
============================================= 经查看 /etc/hosts 文件时间戳,未自动生成(更新)。
The text was updated successfully, but these errors were encountered:
这个应该是 相对路径 的问题(影响了读取 nowip.txt 的位置)。
脚本读写文件,判断 nowip.txt 文件都是相对路径,因此不能使用绝对路径方式去执行脚本。
请把这段:
/root/CloudFlareCDN/cfst_hosts.sh # nowip.txt 被认定为 /root/nowip.txt 或 /nowip.txt 这个路径上了
改为:
cd /root/CloudFlareCDN && bash cfst_hosts.sh # nowip.txt 被正确认定为 /root/CloudFlareCDN/nowip.txt 路径上了
你手动执行也是在 /root/CloudFlareCDN 目录下去执行的吧?如果你在其他目录以绝对路径方式执行脚本也会出现这种问题。
Sorry, something went wrong.
问一下“将hosts文件中所有cloudflare CDN IP设置为一个IP,”这句话怎么理解呢?准确的说就是我在我的VPS的hosts文件中找不到带有cloudflare字样的IP,只能找到127.0.0.1!cfst_hosts是替换这个IP吗?正常有cloudflare CDN IP的hosts是什么样子的?
No branches or pull requests
问题:无法在crontab文件中配置自动执行。
请指导一下,是我哪里配置或使用上有问题。
BTW: 纯手动执行没有问题。我仅仅是想让他按时自动执行,以实现替换hosts文件内容的功能。
crontab内容:
==================================================
/var/log/cron 输出:
==================== 目录内容 ===================
=============================================
经查看 /etc/hosts 文件时间戳,未自动生成(更新)。
The text was updated successfully, but these errors were encountered: