cron error: bad username
Solution 1
* * * * * digger /home/digger/webxass
is the correct syntax.
Solution 2
As it's been answered, the user should be specified. This puzzled me because I'd seen it work without the user on another machine. Just want to add that it is required because it is a system job. From the manual:
Jobs in /etc/cron.d/
The jobs in cron.d and /etc/crontab are system jobs, which are used usually for more than one user, thus, additionally the username is needed. MAILTO on the first line is optional. EXAMPLE OF A JOB IN /etc/cron.d/job
#login as root
#create job with preferred editor (e.g. vim)
MAILTO=root
* * * * * root touch /tmp/file
Source: http://man7.org/linux/man-pages/man5/crontab.5.html
Now, why is it that I had seen /etc/crontab entries without the user apparently working on another machine? Turns out that there was a symlink pointing to it in: /var/spool/cron/crontabs (root -> /etc/crontab). Ha! Not what I'd recommend, by the way.
Solution 3
Your shell script will only run once per hour, to execute it every minute the contents of cat /etc/cron.d/doge
should be as follows:
* * * * * /home/digger/webxass
instead of
1 * * * * /home/digger/webxass
For all errors related to cron jobs, see /var/log/syslog
.
Related videos on Youtube
Alexey Ce
Updated on September 18, 2022Comments
-
Alexey Ce over 1 year
I've basically re-written the terminal output instead of appending a series of edits to this question:
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$
There's some sort of syntax error, but I don't know what it is.
I really don't understand the "bad username" error,
digger
is a valid user. Which username is bad? Thedigger
username in the system?-
SiddharthaRT over 10 yearsTry removing the newline after the command in the file
/home/digger/webxass
-
jobin over 10 yearsWhy are you logged in as root? Does the cron job require those privileges? Did you try installing the cron job as standard/administrative user?
-
-
Alexey Ce over 10 yearsstill doesn't seem to work, I added log output.