openSuse, not running the cron job

| I have created a cron job in the /etc/cron.d/dispatchingEmail_I
|
|

content of the dispatchingEmail_I is:

54 19 * * * root /home/harbir/project/L_ocalRepository/smallworks/maildispatcher.sh >> /tmp/try1.log

The permissions of the above cron file are the following:

-rw-r--r--   1 root root    84 Sep 11 19:52 dispatchingEmail_I

when I check /var/log/messages I can see an entry

2014-09-11T19:54:01.761269+10:00 linux-gn77-PC /USR/SBIN/CRON[4109]: (root) CMD (/home/harbir/project/L_ocalRepository/smallworks/maildispatcher.sh)

which tells me that the command has run, but no email has been received. The log file gets created, but its empty.
where as when I run the script by itself, the email is received.
the permissions of the file maildispatcher.sh are the following:

-rwxrwx---  1 harbir users      621 Sep 10 06:33 maildispatcher.sh

The two reasons that tell me that my script is not getting run via cron job are:

  1. log is empty
  2. script fires up a java program that updates a file before sending an email. The file is not getting updated.

when I run a simple command like

50 05 * * * root echo checking >>/tmp/try2.log 

the cronjob works and has contents in the log file.
can anyone suggest some changes that can be tried?

As far as I know, a cron job has to be an executable program.

To use a shell script, make the command: bash -c /path/to/script

Alternatively, give it “x” permissions and make sure that the first line begin something like “#! /bin/bash -”

https://en.opensuse.org/SDB:Cron

under section /etc/cron.d

"This is the good place when you want to create cron job rule for your package and you want exact date/time of execution. Your crontab rule could be normal file,symlink or hardlink. It have to be owned by root (also write allowed only for root) and not executable. "

I think you may have misunderstood that.

It is talking about the file containing the rule. It is not talking about the shell script command file that is invoked by the rule.

That is about the the defenition file in the /etc/cron.d directory and not about the file/command you want to execute.

The file you want to execute, must be executable (surprise) for the user executing it. In short, when the owner is root, the x-bit must be set for the owner of the file.
And when the file is a scipt, do not forget the shebang (e.g.

#!/bin/bash)

as the first line of the script.

On 2014-09-11 22:26, harbir linuxuser wrote:
>
> I have created a cron job in the
> /etc/cron.d/dispatchingEmail_I
>
>
>
>
> content of the dispatchingEmail_I is:
>
> Code:
> --------------------
> 54 19 * * * root /home/harbir/project/L_ocalRepository/smallworks/maildispatcher.sh >> /tmp/try1.log
> --------------------

If it is going to run as root, why is the script hosted by user
“harbir”? It should be in “/root/bin/”, or maybe “/usr/local/bin/”.

> The permissions of the above cron file are the following:
>
>
> Code:
> --------------------
> -rw-r–r-- 1 root root 84 Sep 11 19:52 dispatchingEmail_I
> --------------------

Ok.

> when I check /var/log/messages I can see an entry
>
>
> Code:
> --------------------
> 2014-09-11T19:54:01.761269+10:00 linux-gn77-PC /USR/SBIN/CRON[4109]: (root) CMD (/home/harbir/project/L_ocalRepository/smallworks/maildispatcher.sh)
> --------------------

Ok.

> which tells me that the command has run, but no email has been received.

Email? What email? :-??

Your dispatchingEmail_I should be like this:


SHELL=/bin/bash
MAILTO="harbir"

54 19 * * * root /root/bin/project/maildispatcher.sh

And then, examine local system email to “harbir” to find out what
happened.

> 2. script fires up a java program that

Does it need to use the display at all? Then it will fail.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

On 2014-09-11 23:26, hcvv wrote:

>
> The file you want to execute, must be executable (surprise) for the user
> executing it. In short, when the owner is root, the x-bit must be set
> for the owner of the file.

Looking at his post, it is executable by the owner:

> Code:
> --------------------
> -rwxrwx— 1 harbir users 621 Sep 10 06:33 maildispatcher.sh
> --------------------

but the cron job calls the script as root, so I guess it will not run.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

Hi all, I have found the issue, its nothing to with the cron job. The script file that I was trying run was refering to the wrong class path, and hence the java program was not running, I will do extra checking next time. Thank you all for helping.