如何诊断 cron.weekly 不每周 运行 的脚本
How diagnose cron.weekly script that doesn't run weekly
我在 /etc/cron.weekly 目录中有一个 python 脚本,名为 example.py
文件顶部有 shebang 行;
#!/usr/bin/env python
文件权限为;
-rwxr-xr-x root root
我是不是漏掉了什么,或者有什么方法可以诊断为什么没有漏掉 运行。可能是错误日志?
删除文件名中的 .py 扩展名。
根据 cron 手册:
The files
under /etc/cron.d do not need to be executable, while the files under /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly and /etc/cron.monthly do, as they are run by run-parts (see
run-parts(8) for more information).
来自 运行-零件手册:
run-parts runs all the executable files named within constraints described below, found in directory directory. Other files and directories are silently ignored.
If neither the --lsbsysinit option nor the --regex option is given then the names must consist entirely of ASCII upper- and lower-case letters, ASCII digits, ASCII underscores, and
ASCII minus-hyphens.
因此,要测试您的脚本是否具有可接受的名称,您可以 运行 以下命令:
run-parts --test /etc/cron.weekly
如果您的脚本在输出中列出,那么您的脚本将被调用。
我在 /etc/cron.weekly 目录中有一个 python 脚本,名为 example.py
文件顶部有 shebang 行;
#!/usr/bin/env python
文件权限为;
-rwxr-xr-x root root
我是不是漏掉了什么,或者有什么方法可以诊断为什么没有漏掉 运行。可能是错误日志?
删除文件名中的 .py 扩展名。
根据 cron 手册:
The files under /etc/cron.d do not need to be executable, while the files under /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly and /etc/cron.monthly do, as they are run by run-parts (see run-parts(8) for more information).
来自 运行-零件手册:
run-parts runs all the executable files named within constraints described below, found in directory directory. Other files and directories are silently ignored.
If neither the --lsbsysinit option nor the --regex option is given then the names must consist entirely of ASCII upper- and lower-case letters, ASCII digits, ASCII underscores, and ASCII minus-hyphens.
因此,要测试您的脚本是否具有可接受的名称,您可以 运行 以下命令:
run-parts --test /etc/cron.weekly
如果您的脚本在输出中列出,那么您的脚本将被调用。