From: JohnT on

Hi,

I've been having odd problems with cron.daily jobs not being run now and
then, but now it has not run for the last few days.

cron.log shows it has run...

Jul 13 06:25:01 xxxxx /USR/SBIN/CRON[18892]: (root) CMD (test -x /usr/
sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ))


But I get none of the emails that it should send.
It works if I manually run:

test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/
cron.daily )

Any ideas where to look for a solution ?

Regards
JohnT
From: Aragorn on
On Wednesday 14 July 2010 09:37 in comp.os.linux.misc, somebody
identifying as JohnT wrote...

>
> Hi,
>
> I've been having odd problems with cron.daily jobs not being run now
> and then, but now it has not run for the last few days.
>
> cron.log shows it has run...
>
> Jul 13 06:25:01 xxxxx /USR/SBIN/CRON[18892]: (root) CMD (test -x /usr/
> sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ))

The fact that it's listed in uppercase is very odd, as UNIX is
case-sensitive...

That said however, I take it that by the above, you mean to say that
cron.log shows that this "test" condition has been executed. However,
the above instruction is an XOR operation - i.e. an "exclusive or" - of
the kind...

"test whether condition A is met" XOR "execute this and this command"

This means that "cd / && run-parts --report /etc/cron.daily" will be
executed if and only if "test -x /usr/sbin/anacron" is false, which in
turn is a test on whether "/usr/sbin/anacron" exists and whether it has
execute permission. So if that file does not exist on your system or
it does exist in the specified directory but does not have execute
permission, then the condition is false and only then will the second
command get executed, i.e. the one that executes the scripts
in "/etc/cron.daily" and sends the mails.

In addition to that, the second part of your command is in itself a
compound and conditional command, which will execute its second
component ("run-parts --report /etc/cron.daily") only if it has
successfully executed the first command ("cd /"). Now, that first
command in itself should not be any problem considering that "cd" is a
shell built-in, but it is my understanding that when Bash is invoked to
run the cron scripts, it does not source "/etc/profile", which is where
the environment variables (and thus your $PATH) are defined.

Possibly Bash does set a minimal $PATH of "/bin:/usr/bin" for
non-interactive shells, but I'm no shell guru so I don't really know,
and in the event that it doesn't, then the command "run-parts" will not
get executed simply because Bash can't find it, since you didn't
include it with its absolute pathname.

Another disclaimer is that I'm not familiar with the way Debian is
organized and what files it sources or scripts it executes. So take my
comments with a grain of salt. ;-)

> But I get none of the emails that it should send.
> It works if I manually run:
>
> test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/
> cron.daily )

As I understand it, the e-mails would normally be sent only if the
second part of the condition gets executed, and considering that the
test for the presence and executability of "/sbin/anacron" on the
system is probably being met by your distribution, the second part of
the condition would normally not get executed.

In other words, if you have "anacron" installed, then, at least, in my
humble opinion, the only thing that gets executed is the test on
whether it exists and has execute permission, not the actual scripts
in "/etc/cron.daily".

> Any ideas where to look for a solution ?

In addition to all of the above, if a program or script executes on one
occasion and not on another while nothing has changed to the system,
then hardware failure (of any form) is to be taken into consideration.

--
*Aragorn*
(registered GNU/Linux user #223157)
From: Pascal Hambourg on
Hello,

Aragorn a �crit :
>>
>> Jul 13 06:25:01 xxxxx /USR/SBIN/CRON[18892]: (root) CMD (test -x /usr/
>> sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ))
>
> The fact that it's listed in uppercase is very odd, as UNIX is
> case-sensitive...

I have the same in the logs on my Debian system too.

> That said however, I take it that by the above, you mean to say that
> cron.log shows that this "test" condition has been executed. However,
> the above instruction is an XOR operation - i.e. an "exclusive or" - of
> the kind...
>
> "test whether condition A is met" XOR "execute this and this command"

No it's not. It is a logical inclusive OR.

> This means that "cd / && run-parts --report /etc/cron.daily" will be
> executed if and only if "test -x /usr/sbin/anacron" is false

Yes, but this is because when the result of the first command is TRUE
the result of the OR operation is TRUE whatever the result of the second
command is, so the second command is not executed because it does not
need to (and here this side effect is used to conditionnaly execute the
second command instead of using an IF structure). If it was an exclusive
OR (XOR), then the second command would need to be executed in all cases
because the final result can never been known only from the result of
the first command.
From: Aragorn on
On Thursday 15 July 2010 13:00 in comp.os.linux.misc, somebody
identifying as Pascal Hambourg wrote...

> Hello,
>
> Aragorn a écrit :
>>>
>>> Jul 13 06:25:01 xxxxx /USR/SBIN/CRON[18892]: (root) CMD (test -x
>>> /usr/ sbin/anacron || ( cd / && run-parts --report /etc/cron.daily
>>> ))
>>
>> The fact that it's listed in uppercase is very odd, as UNIX is
>> case-sensitive...
>
> I have the same in the logs on my Debian system too.

Apparently the person who wrote that application doesn't seem to care
much for accuracy. ;-)

>> That said however, I take it that by the above, you mean to say that
>> cron.log shows that this "test" condition has been executed.
>> However, the above instruction is an XOR operation - i.e. an
>> "exclusive or" - of the kind...
>>
>> "test whether condition A is met" XOR "execute this and this
>> command"
>
> No it's not. It is a logical inclusive OR.
>
>> This means that "cd / && run-parts --report /etc/cron.daily" will be
>> executed if and only if "test -x /usr/sbin/anacron" is false
>
> Yes, but this is because when the result of the first command is TRUE
> the result of the OR operation is TRUE whatever the result of the
> second command is, so the second command is not executed because it
> does not need to (and here this side effect is used to conditionnaly
> execute the second command instead of using an IF structure). If it
> was an exclusive OR (XOR), then the second command would need to be
> executed in all cases because the final result can never been known
> only from the result of the first command.

I stand corrected, Sir. You are right. ;-)

Still, I was right in my assessment as to why his script won't execute,
though. ;-)

--
*Aragorn*
(registered GNU/Linux user #223157)
From: JohnT on
On Thu, 15 Jul 2010 13:27:54 +0200, Aragorn wrote:

>
> I stand corrected, Sir. You are right. ;-)
>
> Still, I was right in my assessment as to why his script won't execute,
> though. ;-)

No.

Because, as I said in my original post, I can run the script manually and
it works.


JohnT