crontab中的脚本未运行
我有一个问题,crontab根本没有运行我的脚本。我已将脚本简化为一行,但仍无法运行:crontab中的脚本未运行,cron,debian,Cron,Debian,我有一个问题,crontab根本没有运行我的脚本。我已将脚本简化为一行,但仍无法运行: $ cat /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the
$ cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
*/1 * * * * root /usr/share/test/script.sh
# don't forget the newline at the end (https://askubuntu.com/a/23337/12057):
$ cat /usr/share/test/script.sh
#!/bin/bash
echo "got here" > /tmp/test.txt
$ ls -l /usr/share/test/script.sh
-rwxr-xr-x 1 root root 951 May 8 08:59 /usr/share/test/script.sh
$ uname -a
Linux mypcname 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux
$ ps aux | grep cron
root 1111 0.0 0.0 22222 3333 ? Ss 08:27 0:00 /usr/sbin/cron
me 4444 0.0 0.0 5555 666 pts/0 S+ 09:06 0:00 grep --color=auto cron
如您所见,crontab应该每分钟运行一次script.sh
,并写入文件/tmp/test.txt
,但是该文件从未出现。我一直在通读,但到目前为止没有一本是适用的。我想一双新的眼睛可能会给我一些启示。每一分钟都是如此
*****
不是
*/1****
相关问题:
/var/log/syslog
给出了答案的线索:
May 8 08:50:01 mypcname /usr/sbin/cron[2222]: (*system*) WRONG FILE OWNER (/etc/crontab)
May 8 08:51:01 mypcname /usr/sbin/cron[2222]: (*system*) WRONG FILE OWNER (/etc/crontab)
$ ls -l /etc/crontab
lrwxrwxrwx 1 root root 24 Oct 12 2013 /etc/crontab -> /home/me/.crontab
$ ls -l ~/.crontab
-rw-r--r-- 1 root root 24 Oct 12 2013 /home/me/.crontab
我记得我在安装debian操作系统时就是这么做的,因为我的home目录中的所有内容都是从subversion存储库中签出的。我这样解决了这个问题:
$ sudo cp ~/.crontab /etc/crontab
现在一切都正常了:)系统日志是怎么回事?通常,cron作业执行会记录在那里