[英]cron job not started daily
I have a script in /etc/cron.daily/backup.sh file is allowed to execute and run but do not start happening, I read the manual and used the search but not mastered decision. 我在/etc/cron.daily/backup.sh文件中有一个脚本允许执行和运行但是没有开始发生,我阅读了手册并使用了搜索但没有掌握的决定。
ls -l /etc/cron.daily/
total 52
-rwxr-xr-x 1 root root 8686 2009-04-17 10:27 apt
-rwxr-xr-x 1 root root 314 2009-02-10 19:45 aptitude
-rwxr-xr-x 1 root root 103 2011-05-22 19:08 backup.sh
-rwxr-xr-x 1 root root 502 2008-11-05 03:43 bsdmainutils
-rwxr-xr-x 1 root root 89 2009-01-27 00:55 logrotate
-rwxr-xr-x 1 root root 954 2009-03-19 16:17 man-db
-rwxr-xr-x 1 root root 646 2008-11-05 03:37 mlocate
The cron job filename can't have a period in it on certain ubuntus. 在某些ubuntus上,cron作业文件名不能包含句点。 See this . 看到这个 。 Particularly, this quote within: 特别是,这句话在:
Although the directories contain periods in their names, run-parts will not accept a file name containing a period and will fail silently when encountering them 虽然目录名称中包含句点,但运行部分不接受包含句点的文件名,并且在遇到它们时将无声地失败
Properly, this is a problem with run-parts, which the ubuntu cron runs, and not with cron itself. 正确地说,这是运行部件的问题,ubuntu cron运行,而不是cron本身。 Still, it's what bit me. 不过,这就是我的意思。
pls check: 请检查:
1a) is the script executable and has correct owner/group settings? 1a)脚本是否可执行并且具有正确的所有者/组设置?
1b) does it start with the correct #! 1b)从正确的#开始! line? 线? and do you specify the full path to the shell you're using, eg #!/bin/bash ? 你指定了你正在使用的shell的完整路径,例如#!/ bin / bash?
2) does the script generate an error while being executed? 2)脚本在执行时是否会生成错误? eg can you write to a log file from it, and do you see the log messages? 例如,你可以从它写入一个日志文件,你看到日志消息吗?
also: check in the email inbox of the user who owns the crontab -- errors are emailed to the user / eg root 另外:检查拥有crontab的用户的电子邮件收件箱 - 错误通过电子邮件发送给用户/例如root
what does the output of ls -l /etc/cron.daily/
look like? ls -l /etc/cron.daily/
的输出是什么样的? can you post that? 你能发贴吗?
NOTE: 注意:
you can always create a crontab entry for this yourself, outside of those cron.xxx directory structure ;-) 您可以随时在cron.xxx目录结构之外为此创建一个crontab条目;-)
See: man 5 crontab
见: man 5 crontab
10 1 * * * /somewhere/backup.sh >> /somewhere/backup.log 2>&1
this has the advantage that you get to pick the exact time when it runs (eg 1:10am here), and you can redirect STRERR and STDOUT to append to a log file for that particular script 这样做的好处是你可以选择运行时的确切时间(例如,这里是1:10),你可以重定向STRERR和STDOUT以附加到该特定脚本的日志文件中
For testing purposes you could run it ever 10 minutes, like this: 出于测试目的,您可以运行它10分钟,如下所示:
0,10,20,30,40,50 * * * * /somewhere/backup.sh >> /somewhere/backup.log 2>&1
do touch /somewhere/backup.log
to make sure it exists touch /somewhere/backup.log
以确保它存在
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.