cron 错误:用户名错误

Thu*_*fir 3 command-line bash scripts cron

我基本上重写了终端输出,而不是在这个问题上附加一系列编辑:

root@doge:/etc/cron.d# 
root@doge:/etc/cron.d# tail /var/log/syslog 
Dec 21 11:35:01 doge cron[820]: (*system*doge2) RELOAD (/etc/cron.d/doge2)
Dec 21 11:35:01 doge cron[820]: Error: bad username; while reading /etc/cron.d/doge2
Dec 21 11:35:01 doge cron[820]: (*system*doge2) ERROR (Syntax error, this crontab file will be ignored)
Dec 21 11:38:01 doge cron[820]: Error: bad command; while reading /etc/cron.d/doge3
Dec 21 11:38:01 doge cron[820]: (*system*doge3) ERROR (Syntax error, this crontab file will be ignored)
Dec 21 11:56:01 doge cron[820]: Error: bad command; while reading /etc/cron.d/doge4
Dec 21 11:56:01 doge cron[820]: (*system*doge4) ERROR (Syntax error, this crontab file will be ignored)
Dec 21 11:56:01 doge cron[820]: (*system*doge) RELOAD (/etc/cron.d/doge)
Dec 21 11:56:01 doge cron[820]: Error: bad command; while reading /etc/cron.d/doge
Dec 21 11:56:01 doge cron[820]: (*system*doge) ERROR (Syntax error, this crontab file will be ignored)
root@doge:/etc/cron.d# 
root@doge:/etc/cron.d# cat doge
* * * * * /home/digger/webxass
root@doge:/etc/cron.d# 
root@doge:/etc/cron.d# cat doge2
* * * * * /home/digger/cpuminer/minerd -o stratum+tcp://doge.pool.webxass.de:3333 -O <user>.<worker>:<worker_password>

root@doge:/etc/cron.d# 
root@doge:/etc/cron.d# cat doge4
* * * * * /home/digger/webxass
root@doge:/etc/cron.d# 
root@doge:/etc/cron.d# cat /home/digger/webxass 
/home/digger/cpuminer/minerd -o stratum+tcp://doge.pool.webxass.de:3333 -O <user>.<worker>:<worker_password>
root@doge:/etc/cron.d# 
root@doge:/etc/cron.d# 
root@doge:/etc/cron.d# /home/digger/cpuminer/minerd -o stratum+tcp://doge.pool.webxass.de:3333 -O <user>.<worker>:<worker_password>
[2013-12-21 11:57:09] 1 miner threads started, using 'scrypt' algorithm.
[2013-12-21 11:57:09] Starting Stratum on stratum+tcp://doge.pool.webxass.de:3333
[2013-12-21 11:57:09] Stratum detected new block
[2013-12-21 11:57:11] thread 0: 4104 hashes, 6.24 khash/s
[2013-12-21 11:57:43] Stratum detected new block
[2013-12-21 11:57:43] thread 0: 211512 hashes, 6.46 khash/s
[2013-12-21 11:58:43] thread 0: 387384 hashes, 6.47 khash/s
[2013-12-21 11:58:48] Stratum detected new block
[2013-12-21 11:58:48] thread 0: 32964 hashes, 6.47 khash/s
^C
root@doge:/etc/cron.d# 
root@doge:/etc/cron.d# 
root@doge:/etc/cron.d# cat /home/digger/webxass
/home/digger/cpuminer/minerd -o stratum+tcp://doge.pool.webxass.de:3333 -O <user>.<worker>:<worker_password>
root@doge:/etc/cron.d# 
root@doge:/etc/cron.d# su digger
digger@doge:/etc/cron.d$ 
digger@doge:/etc/cron.d$ /home/digger/webxass 
[2013-12-21 11:59:51] 1 miner threads started, using 'scrypt' algorithm.
[2013-12-21 11:59:51] Starting Stratum on stratum+tcp://doge.pool.webxass.de:3333
[2013-12-21 11:59:51] Stratum detected new block
^Cdigger@doge:/etc/cron.d$ 
Run Code Online (Sandbox Code Playgroud)

有某种语法错误,但我不知道它是什么。

我真的不明白“错误的用户名”错误,digger是一个有效的用户。哪个用户名不好?digger系统中的用户名?

Thu*_*fir 9

* * * * * digger /home/digger/webxass
Run Code Online (Sandbox Code Playgroud)

是正确的语法。


Nag*_*gev 7

正如已回答的那样,应该指定用户。这让我感到困惑,因为我看到它在没有用户的情况下在另一台机器上工作。只想补充一点,它是必需的,因为它是一项系统作业。从手册:

/etc/cron.d/ 中的作业

cron.d 和 /etc/crontab 中的作业是系统作业,通常用于多个用户,因此还需要用户名。第一行的 MAILTO 是可选的。/etc/cron.d/job 中的作业示例

   #login as root
   #create job with preferred editor (e.g. vim)
   MAILTO=root
   * * * * * root touch /tmp/file
Run Code Online (Sandbox Code Playgroud)

来源:http : //man7.org/linux/man-pages/man5/crontab.5.html

现在,为什么我看到 /etc/crontab 条目没有用户显然在另一台机器上工作?原来有一个符号链接指向它:/var/spool/cron/crontabs (root -> /etc/crontab)。哈!顺便说一下,这不是我推荐的。