Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Weird cron email
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
kajzer
Guru
Guru


Joined: 27 Nov 2014
Posts: 422

PostPosted: Sat Mar 16, 2019 11:58 am    Post subject: [Solved] Weird cron email Reply with quote

Every day I get email from cron, it's not a big deal but it bugs me why I get them.
I have 3 scripts in cron.daily, all got there via emerging packages.
logrotate, man-db and mlocate

Email subject is :
cron for user root root test -e /run/systemd/system || //sbin/e2scrub_all -A -r

with this message :
/bin/sh: root: command not found

I know that this message 'root: command not found' comes when the path to the executable is not specified, from those three scripts only man-db doesn't have one and the last line is :
exec nice mandb --quiet

now, I've changed that to 'exec nice /usr/bin/mandb --quiet'
but it didn't help.

I don't know what else could it be and from where this is coming from, any clues?


Last edited by kajzer on Sun Mar 17, 2019 6:30 am; edited 1 time in total
Back to top
View user's profile Send private message
mike155
Veteran
Veteran


Joined: 17 Sep 2010
Posts: 1189
Location: Frankfurt, Germany

PostPosted: Sat Mar 16, 2019 4:58 pm    Post subject: Reply with quote

Quote:
/run/systemd/system || //sbin/e2scrub_all -A -r

That doesn't look like mandb. It looks like: https://github.com/tytso/e2fsprogs/blob/master/scrub/e2scrub_all.service.in
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13730

PostPosted: Sat Mar 16, 2019 5:11 pm    Post subject: Re: Weird cron email Reply with quote

kajzer wrote:
it's not a big deal but it bugs me why I get them.
You get them because they produce output. Cron jobs should be silent unless they have important messages for the operator.
kajzer wrote:
Email subject is :
cron for user root root test -e /run/systemd/system || //sbin/e2scrub_all -A -r

with this message :
/bin/sh: root: command not found

I know that this message 'root: command not found' comes when the path to the executable is not specified
In this case, it's because you don't have a program named root on your path. Cron is trying to run a program named root. This is probably a bug: a crontab meant for consumption by the system crontab (which takes an explicit username) was used where a crontab with implicit ownership was expected.
Back to top
View user's profile Send private message
kajzer
Guru
Guru


Joined: 27 Nov 2014
Posts: 422

PostPosted: Sat Mar 16, 2019 5:14 pm    Post subject: Reply with quote

mike155 wrote:
Quote:
/run/systemd/system || //sbin/e2scrub_all -A -r

That doesn't look like mandb. It looks like: https://github.com/tytso/e2fsprogs/blob/master/scrub/e2scrub_all.service.in


I didn't said it was mandb

To me it looks like it's test -e /run/systemd/system
should be /usr/bin/test -e ...

but I don't know where that is / which file to edit / what's calling it.
Back to top
View user's profile Send private message
kajzer
Guru
Guru


Joined: 27 Nov 2014
Posts: 422

PostPosted: Sat Mar 16, 2019 5:27 pm    Post subject: Reply with quote

mike155 wrote:
Quote:
/run/systemd/system || //sbin/e2scrub_all -A -r

That doesn't look like mandb. It looks like: https://github.com/tytso/e2fsprogs/blob/master/scrub/e2scrub_all.service.in


Actually you might be right, there's a file /etc/cron.d/e2scrub_all , inside is this :

Code:
30 3 * * 0 root test -e /run/systemd/system || /usr/lib64/e2fsprogs/e2scrub_all_cron
10 3 * * * root test -e /run/systemd/system || //sbin/e2scrub_all -A -r


I'll delete root from this and I guess it will probably solve it.
problem was described here, but I wasn't able to find what's calling it in my case.
http://rhosted.blogspot.com/2010/04/crontab-error-binsh-root-command-not.html

It will run in several hours so I guess I'll know it then.


Last edited by kajzer on Sat Mar 16, 2019 7:24 pm; edited 1 time in total
Back to top
View user's profile Send private message
russK
l33t
l33t


Joined: 27 Jun 2006
Posts: 626

PostPosted: Sat Mar 16, 2019 7:03 pm    Post subject: Reply with quote

The man page for crontab says,
Code:
The sixth field of a line in a crontab entry is a string that shall be executed by 'sh' at the specified times.

So unless you have something named 'root' that you want to be executed, it would be right to remove it.

HTH
Back to top
View user's profile Send private message
mike155
Veteran
Veteran


Joined: 17 Sep 2010
Posts: 1189
Location: Frankfurt, Germany

PostPosted: Sat Mar 16, 2019 9:24 pm    Post subject: Reply with quote

Quote:
there's a file /etc/cron.d/e2scrub_all:
Code:
10 3 * * * root test -e /run/systemd/system || //sbin/e2scrub_all -A -r

That could be the origin of the problem. But I'm not convinced... Because the cron man page explicitly states that entries in /etc/crontab and in /etc/cron.d/* need a username in column 6. The line is correct.
  1. Which cron do you use? vixie-cron?

  2. Are there any non-visible characters in that line? Especially between '*' and 'root'?

  3. Just to make sure that we are looking at the right location: please execute the statements below
    Code:
    cd /etc
    grep -r e2scrub_all .
    cd /var/spool/cron/crontabs
    grep -r e2scrub_all .

    Are there any other files where e2scrub_all gets executed?

  4. What happens if you execute the program manually?
    Code:
    //sbin/e2scrub_all -A -r

    Do you get any errors?
Back to top
View user's profile Send private message
russK
l33t
l33t


Joined: 27 Jun 2006
Posts: 626

PostPosted: Sat Mar 16, 2019 10:32 pm    Post subject: Reply with quote

BTW, the man page that I referenced is a standard POSIX crontab man page that came from sys-apps/man-pages-posix-2013a.

Regards
Back to top
View user's profile Send private message
mike155
Veteran
Veteran


Joined: 17 Sep 2010
Posts: 1189
Location: Frankfurt, Germany

PostPosted: Sat Mar 16, 2019 10:55 pm    Post subject: Reply with quote

russK wrote:
The sixth field of a line in a crontab entry is a string that shall be executed by 'sh' at the specified times.

BTW, the man page that I referenced is a standard POSIX crontab man page that came from sys-apps/man-pages-posix-2013a.

That's true for user crontabs (crontab -e) - but not for system crontabs (files /etc/crontab and /etc/cron.d/*)

The vixie crontab man page (man 5 crontab) says:
Quote:
Each line has five time and date fields, followed by a user name if this is the system crontab file, followed by a command.

Later on the same page it says:
Quote:
The "sixth" field (the rest of the line) specifies the command to be run.

But that's true only for user crontabs. User crontabs don't need a field "user", because commands will be executed under the user who owns the crontab.

If you don't believe me: install a package that installs files to /etc/cron.d. app-admin/sysstat, for example. And the look at /etc/cron.d/systat:
Code:
# Run system activity accounting tool every 10 minutes
# */10 * * * * root /usr/lib64/sa/sa1 1 1
# 0 * * * * root /usr/lib64/sa/sa1 600 6 &
# Generate a text summary of previous day process accounting at 00:07
# 7 0 * * * root /usr/lib64/sa/sa2 -A

PS: I just looked at the POSIX crontab man page you cited. That's /usr/share/man/man1p/crontab.1p.bz2, right? Well, that man page only talks about the program 'crontab', which is used to manage user crontabs. It does not talk about system crontabs (files /etc/crontab and /etc/cron.d/*).
Back to top
View user's profile Send private message
kajzer
Guru
Guru


Joined: 27 Nov 2014
Posts: 422

PostPosted: Sat Mar 16, 2019 11:18 pm    Post subject: Reply with quote

@mike155,

I use dcron

Code:
# cd /etc
# grep -r e2scrub_all .                                                                                                                                                                                               
./cron.d/e2scrub_all:30 3 * * 0 test -e /run/systemd/system || /usr/lib64/e2fsprogs/e2scrub_all_cron
./cron.d/e2scrub_all:10 3 * * * test -e /run/systemd/system || //sbin/e2scrub_all -A -r
./e2scrub.conf:# Set this to 1 to have e2scrub_all scrub all LVs, not just the mounted ones.
# cd /var/spool/cron/crontabs
# grep -r e2scrub_all .
#


I believe it will be solved after the changes, that's why you can't see 'root' above, because I changed that file, but I posted earlier that file with 'root' before 'test....'
If it doesn't we can look at this further, otherwise I'll say it's fine and mark this as solved :)
Back to top
View user's profile Send private message
mike155
Veteran
Veteran


Joined: 17 Sep 2010
Posts: 1189
Location: Frankfurt, Germany

PostPosted: Sun Mar 17, 2019 12:22 am    Post subject: Reply with quote

@kajzer:

thanks for your response.

I looked at the source code of drcon. dcron doesn't seem to support the username field in /etc/crontab or /etc/cron.d/*.

For that reason, it's the right solution to remove that field in /etc/cron.d/e2scrub_all (and in all other files that are/will be installed in /etc/cron.d) on your machine.
Back to top
View user's profile Send private message
kajzer
Guru
Guru


Joined: 27 Nov 2014
Posts: 422

PostPosted: Sun Mar 17, 2019 6:30 am    Post subject: Reply with quote

It worked, thank you all!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum