我无法通过将 cron 作业放置在 /etc/cron.hourly 文件夹中来配置它来运行。
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
Run Code Online (Sandbox Code Playgroud)
cron.hourly 下的文件是:
lrwxrwxrwx 1 root root 40 2010-07-26 14:52 check -> /usr/local/xxxx/check-interface.bash
Run Code Online (Sandbox Code Playgroud)
文件权限:
-rwxr-xr-x 1 root root 1.6K 2010-09-13 11:22 /usr/local/xxxx/check-interface.bash
Run Code Online (Sandbox Code Playgroud)
var/log/cron 日志文件中似乎没有报告错误。没有提到脚本。:(
为了隔离问题,将 /usr/local/xxxx/check-interface.bash 移动到 /etc/cron.hourly/check ,然后查看它是否运行。
如果脚本确实运行,则问题是由所有权/权限或相关问题引起的,这些问题阻止 cron 执行 /usr/local/xxxx/* 处的脚本。
如果脚本不运行,则问题很可能出在脚本本身。
作为另一项健全性检查,将 的内容替换/usr/local/xxxx/check-interface.bash为非常简单的内容,例如:
date > /tmp/check-interfaces.log 2>&1
Run Code Online (Sandbox Code Playgroud)
然后查看 /tmp/check-interfaces.log 是否确实由您的 cronjob 填充。如果它确实有效,那么问题一定出在您的原始脚本上。