crontab定时任务/bin/sh: root: command not found

crontab定时任务/bin/sh: root: command not found

命令crontab -e(错误写法)

 * * * * *  root /var/www/run.sh

命令crontab -e(正确写法)

  • 无需加入root,具体如下。
 * * * * *   /var/www/run.sh

/etc/crontab文件和crontab -e命令区别

1、格式不同
# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed

和
* 1 * * *  command

2、使用范围

修改/etc/crontab这种方法只有root用户能用,这种方法更加方便与直接直接给其他用户设置计划任务,而且还可以指定执行shell等等,

crontab -e这种所有用户都可以使用,普通用户也只能为自己设置计划任务。然后自动写入/var/spool/cron/usename

posted @ 2022-07-22 15:27  三号小玩家  阅读(543)  评论(0)    收藏  举报
Title
三号小玩家的 Mail: 17612457115@163.com, 联系QQ: 1359720840 微信: QQ1359720840