wenhq
发表于 2013-05-02 09:46
more /var/spool/cron/crontabs/*
abcfy2
发表于 2013-05-02 09:58
回复 9# wenhq ok988@iotdemo:~$ more /var/spool/cron/crontabs/*
/var/spool/cron/crontabs/*: Permission denied
ok988@iotdemo:~$ sudo more /var/spool/cron/crontabs/*
password for ok988:
/var/spool/cron/crontabs/*: No such file or directory
ok988@iotdemo:~$
abcfy2
发表于 2013-05-02 10:07
回复 11# wenhq
不对,进入目录可以看到ok988这个账户的cron任务。以前写入/etc/contab的,后来就把crontab的任务删了,直接用ok988这个账户创建crontab -e来创建cron任务root@iotdemo:/var/spool/cron/crontabs# ll
total 12
drwx-wx--T 2 rootcrontab 4096 May1 19:49 ./
drwxr-xr-x 5 rootroot 4096 Sep 242012 ../
-rw------- 1 ok988 crontab 1429 May1 19:49 ok988
root@iotdemo:/var/spool/cron/crontabs# vim ok988
root@iotdemo:/var/spool/cron/crontabs#
wenhq
发表于 2013-05-02 10:28
大小不为0, 你先file ok988 然后more ok988.
abcfy2
发表于 2013-05-02 11:20
回复 14# wenhq root@iotdemo:/var/spool/cron/crontabs# ll
total 12
drwx-wx--T 2 rootcrontab 4096 May2 10:02 ./
drwxr-xr-x 5 rootroot 4096 Sep 242012 ../
-rw------- 1 ok988 crontab 1429 May1 19:49 ok988
root@iotdemo:/var/spool/cron/crontabs# file ok988
ok988: UTF-8 Unicode English text
root@iotdemo:/var/spool/cron/crontabs# more ok988
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.KxeMx8/crontab installed on Wed May1 19:49:15 2013)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m hdom mon dow command
SHELL=/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
#每天4:00执行mysql备份
0 4 * * * ~/mysql_backup/mysql_backup.sh >> /tmp/mysql_backup.log
#每6小时执行磁盘空间监测,超过预警给管理员发邮件
0 */6 * * * ~/monitor_disk.sh >> /tmp/monitor_disk.log
root@iotdemo:/var/spool/cron/crontabs#
wenhq
发表于 2013-05-02 11:44
你的脚本写绝对路径吧。为啥写相对路径?
abcfy2
发表于 2013-05-02 11:54
回复 16# wenhq
早就试过了,都不行,绝对路径也是not found,相对路径在mail中也显示的绝对路径,都执行不了
wenhq
发表于 2013-05-02 12:12
ls -l urscript 看下权限
abcfy2
发表于 2013-05-02 12:38
回复 18# wenhq ok988@iotdemo:~$ ll monitor_disk.sh
-rwxr-xr-x 1 ok988 ok988 1811 May1 19:49 monitor_disk.sh*
ok988@iotdemo:~$ ll mysql_backup/mysql_backup.sh
-rwxr-xr-x 1 ok988 ok988 1014 May1 19:21 mysql_backup/mysql_backup.sh*
刚才试了下,把/home/ok988的权限改为755就可以执行脚本了,看来真的是cron没有用当前用户的身份来执行?奇怪了,别的服务器上也是这样设置的,都没有问题,偏偏这台服务器出问题了
wenhq
发表于 2013-05-02 13:24
回复 19# abcfy2
more /etc/cron.*
看一下。