Chinaunix首页 | 论坛 | 博客
  • 博客访问: 321306
  • 博文数量: 72
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 748
  • 用 户 组: 普通用户
  • 注册时间: 2018-09-21 18:49
文章分类

全部博文(72)

我的朋友

分类: LINUX

2018-11-20 19:21:20

一发现问题
(1)crontab -e
*/1 * * * * student date >> /tmp/date
(2)cat /tmp/date 发现并没有内容
        tail -f /var/log/cron
         发现计划任务在执行,
(3) crontab -e
*/1 * * * * student date &>>/tmp/date
(4)cat /tmp/date  发现文件里面有如下错误内容
   /bin/bash:student:command not found
(5)crontab -l -u student  报错
二 解决
  1(1)vim /etc/crontab
     */1 * * * * student date >>/tmp/date
   (2)cat /tmp/date  文件里面有预想的内容 恢复正常
   2  (1)su - student
         以用户student身份创建计划任务
           */1 * * * * date >>/tmp/date
   3  cat /tmp/date  发现内容正常
  4  切换到root用户
     crontab -l -u student 显示如下内容,没有报错,说明正常
      */1 * * * * date >>/tmp/date
总结:(1)crontab -e 命令是当前用户在执行计划任务,如果指定用户的话,系统会把用户名当作命令来执行,所以报命令没有找到的错误
(2)要想指定某一个用户 要么在配置文件/etc/crontab里面设置,要么切换到指定用户再用
crontab -e命令
阅读(878) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~