错误:用户名错误;读取 /etc/crontab 时

sef*_*oub 4 nfs cron rsync

我想将文件从服务器复制到已安装在服务器上的 NFS。

为此,我配置了一个 crontab 将这些文件复制到 NFS。通过手动输入命令,文件已成功复制,但通过使用 crontab 自动化主题,它总是告诉我 Error: bad username; while reading /etc/crontab

这是 crontab 配置:

# 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 )

#

*/5 * * * admindp cp -r /srv/wildfly/email_templates/ /mnt/sharedfolder_client/wildfly/email_templates/

*/5 * * * admindp cp -r /srv/ma/dataprotect/sensiproImages /mnt/sharedfolder_client/sensiproImages/

*/5 * * * * admindp cp -r /var/log/tomcat8/sensiproscheduler-app.log /shared_ftp/
Run Code Online (Sandbox Code Playgroud)

ste*_*ver 5

系统范围/etc/crontab文件中的 cron 作业规范与普通用户 crontab 中的规范不同。如中所述man 5 cron

   The system crontab (/etc/crontab) uses the same format, except that the
   username  for  the  command is specified after the time and date fields
   and before the command. The fields may be separated by spaces or  tabs.
   The maximum permitted length for the command field is 998 characters.
Run Code Online (Sandbox Code Playgroud)

请注意,用户名必须紧接在时间规范之后rsync因此,假设您想以用户身份运行命令admindp

*/5 * * * *     admindp     rsync -r /var/log/tomcat8/sensiproscheduler-app.log /shared_ftp/
Run Code Online (Sandbox Code Playgroud)