LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cron not executing (https://www.linuxquestions.org/questions/linux-newbie-8/cron-not-executing-604064/)

colucix 12-04-2007 04:17 AM

Quote:

Originally Posted by yusufs (Post 2979556)
where i can see the cronjob logs of the user

You can check the mail of the user (that one accessed by the mail command). Usually logs are sent there, unless you specify a different user or address with the MAILTO variable (or assign an empty string to disable logs).

Edit: you can try also to look at /var/log/maillog (if it exists). Once I had a similar problem with sendmail and the error message from the mail server was
Code:

Domain of sender address user@host does not exist
I solved by adding option -f to the sendmail command.

matthewg42 12-04-2007 04:44 AM

I cannot make sense of what you write.
 
Quote:

Originally Posted by yusufs
after the cron is ran, /tmp/my_alert_test.log is not created

Quote:

Originally Posted by yusufs (Post 2979556)
Cron is working fine..

You are not giving me consistent information. How did you determine that cron is working when the test I asked you do to to see if it is working showed that it is not?

Quote:

Originally Posted by yusufs (Post 2979556)
where i can see the cronjob logs of the user

It depends on which cron daemon your system is using, how it is configured and, and how syslog is configured. This is distro specific, so I cannot say for your machine with certainty. It is not even certain that cron jobs are logged on a job-by-job basis. This is the reason I asked you to do the test - to see if cron is running jobs for you - this method doesn't require any knowledge of your system's cron daemon configuration.

matthewg42 12-04-2007 04:49 AM

On Debain Etch and Ubuntu 7.10 systems in default configurations cron job logging is done to /var/log/syslog. You can find the jobs for a specific user like this:
Code:

grep CRON /var/log/syslog |grep username
...of course substituting username for the one you are interested in. You will only be able to run this command if you are in the group syslog or are root on the system.

If you use another distro, I don't know.

yusufs 12-04-2007 06:06 AM

Quote:

Originally Posted by matthewg42 (Post 2979592)
On Debain Etch and Ubuntu 7.10 systems in default configurations cron job logging is done to /var/log/syslog. You can find the jobs for a specific user like this:
Code:

grep CRON /var/log/syslog |grep username
...of course substituting username for the one you are interested in. You will only be able to run this command if you are in the group syslog or are root on the system.

If you use another distro, I don't know.




mathew,

Thanks for your patience and answers..cron is executing am getting the following mail :

From oracrp@oracle.ali.com.kw Tue Dec 4 14:34:01 2007
Return-Path: <oracrp@oracle.ali.com.kw>
Received: from oracle.ali.com.kw (localhost.localdomain [127.0.0.1])
by oracle.ali.com.kw (8.13.1/8.13.1) with ESMTP id lB4BY1CI005169
for <oracrp@oracle.ali.com.kw>; Tue, 4 Dec 2007 14:34:01 +0300
Received: (from oracrp@localhost)
by oracle.ali.com.kw (8.13.1/8.13.1/Submit) id lB4BY1it005164;
Tue, 4 Dec 2007 14:34:01 +0300
Date: Tue, 4 Dec 2007 14:34:01 +0300
Message-Id: <200712041134.lB4BY1it005164@oracle.ali.com.kw>
From: root@oracle.ali.com.kw (Cron Daemon)
To: oracrp@oracle.ali.com.kw
Subject: Cron <oracrp@oracle> /home/oracrp/test/test.sh
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/oracrp>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=oracrp>
X-Cron-Env: <USER=oracrp>

/bin/sh: /home/oracrp/test/test.sh: Permission denied
You have mail in /var/spool/mail/oracrp


Please guide
Yusuf

yusufs 12-04-2007 06:09 AM

Quote:

Originally Posted by yusufs (Post 2979636)
mathew,

Thanks for your patience and answers..cron is executing am getting the following mail :

From oracrp@oracle.ali.com.kw Tue Dec 4 14:34:01 2007
Return-Path: <oracrp@oracle.ali.com.kw>
Received: from oracle.ali.com.kw (localhost.localdomain [127.0.0.1])
by oracle.ali.com.kw (8.13.1/8.13.1) with ESMTP id lB4BY1CI005169
for <oracrp@oracle.ali.com.kw>; Tue, 4 Dec 2007 14:34:01 +0300
Received: (from oracrp@localhost)
by oracle.ali.com.kw (8.13.1/8.13.1/Submit) id lB4BY1it005164;
Tue, 4 Dec 2007 14:34:01 +0300
Date: Tue, 4 Dec 2007 14:34:01 +0300
Message-Id: <200712041134.lB4BY1it005164@oracle.ali.com.kw>
From: root@oracle.ali.com.kw (Cron Daemon)
To: oracrp@oracle.ali.com.kw
Subject: Cron <oracrp@oracle> /home/oracrp/test/test.sh
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/oracrp>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=oracrp>
X-Cron-Env: <USER=oracrp>

/bin/sh: /home/oracrp/test/test.sh: Permission denied
You have mail in /var/spool/mail/oracrp


Please guide
Yusuf

added to it FYI


[root@oracle etc]# cat /etc/cron.deny
[root@oracle etc]# cat /etc/cron.allow
ALL
oracrp

matthewg42 12-04-2007 06:40 AM

Hmm, strange. This permission denied message is the heart of the problem.

OK, please execute these commands and paste the output:
Code:

ls -l /bin/bash
ls -l /home/oracrp/test/test.sh
mount |grep $(df -k /home/oracrp/test |awk 'NR==2 { print $1 }')
df -k /tmp
ls -ld /tmp

A short explanation of what I am looking for with these commands:

The first is to see the permissions and location of the bash executable (which /bin/sh is a link to as determined from previous posts)

I want to double check the permissions and ownership of the script file, and make sure the path is correct.

I want to check the mount flags for the directory where the script is located, this time explicitly with the path seen in the email (that's the mount command)

The test script is making a file in /tmp - lets be sure there is disk space free (df)

In case something very weird is happening, your /tmp directory should be writable, so the last command is there just to verify this.

yusufs 12-04-2007 07:29 AM

Quote:

Originally Posted by matthewg42 (Post 2979661)
Hmm, strange. This permission denied message is the heart of the problem.

OK, please execute these commands and paste the output:
Code:

ls -l /bin/bash
ls -l /home/oracrp/test/test.sh
mount |grep $(df -k /home/oracrp/test |awk 'NR==2 { print $1 }')
df -k /tmp
ls -ld /tmp

A short explanation of what I am looking for with these commands:

The first is to see the permissions and location of the bash executable (which /bin/sh is a link to as determined from previous posts)

I want to double check the permissions and ownership of the script file, and make sure the path is correct.

I want to check the mount flags for the directory where the script is located, this time explicitly with the path seen in the email (that's the mount command)

The test script is making a file in /tmp - lets be sure there is disk space free (df)

In case something very weird is happening, your /tmp directory should be writable, so the last command is there just to verify this.




Mathew, Thanks .. here it is :




[oracrp@oracle test]$ ls -l /bin/bash
-rwxr-xr-x 1 root root 616248 Apr 12 2006 /bin/bash
[oracrp@oracle test]$ ls -l /home/oracrp/test/test.sh
-rwxr-xr-x 1 oracrp dba 47 Dec 4 15:15 /home/oracrp/test/test.sh
[oracrp@oracle test]$ mount |grep $(df -k /home/oracrp/test |awk 'NR==2 { print $1 }')
/dev/cciss/c0d0p1 on / type ext3 (rw)
[oracrp@oracle test]$ df -k /tmp
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/cciss/c0d0p1 25199660 7916216 16003348 34% /
[oracrp@oracle test]$ ls -ld /tmp
drwxrwxrwt 26 root root 4096 Dec 4 16:18 /tmp




Yusuf

matthewg42 12-04-2007 07:37 AM

I can't see anything wrong there.

What happens if you run the script using the full path (no sh at the start):
Code:

/home/oracrp/test/test.sh

yusufs 12-04-2007 03:13 PM

Quote:

Originally Posted by matthewg42 (Post 2979707)
I can't see anything wrong there.

What happens if you run the script using the full path (no sh at the start):
Code:

/home/oracrp/test/test.sh



Mathew,

the command works fine....
I really thank you for your patience for being with me to solve this issue all around.


Yusuf

matthewg42 12-04-2007 03:44 PM

This is really strange. The command works from the command line but you get the permission denied from cron... I am unable to understand it. I am completely out of ideas... :(

chrism01 12-04-2007 05:07 PM

Try logging in as root (or ask him to do so) and check his emails. cron usually emails root or the crontab owner if it has a problem.

matthewg42 12-05-2007 01:11 AM

Quote:

Originally Posted by chrism01 (Post 2980265)
Try logging in as root (or ask him to do so) and check his emails. cron usually emails root or the crontab owner if it has a problem.

He sees a mail from the cron daemon. See post 20. It looks like the job is triggering, but there is an error:
Quote:

Subject: Cron <oracrp@oracle> /home/oracrp/test/test.sh
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/oracrp>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=oracrp>
X-Cron-Env: <USER=oracrp>

/bin/sh: /home/oracrp/test/test.sh: Permission denied
You have mail in /var/spool/mail/oracrp
You have any ideas?

yusufs 12-05-2007 01:31 AM

[QUOTE=matthewg42;2980659]He sees a mail from the cron daemon. See post 20. It looks like the job is triggering, but there is an error:

You have any ideas?[/QUOTE

Mathew and Chrism,

In addition to the above, I've added the user to cron.allow and no users are there in cron.deny


Thanks
Yusuf

yusufs 12-05-2007 03:19 AM

Mathew and chris,

Got it.. when running the same script as root user it is executing fine and sends the mail.. whereas non root user cannot..it gives the error :


/bin/sh: /home/oracrp/test/test.sh: Permission denied


[oracrp@oracle test]$ ls -rlt /bin/sh
lrwxrwxrwx 1 root root 4 May 24 2007 /bin/sh -> bash
[oracrp@oracle test]$ ls -rlt /home/oracrp/test/test.sh
-rwxr-xr-x 1 oracrp dba 47 Dec 4 15:15 /home/oracrp/test/test.sh



Comments please

Yusuf

matthewg42 12-05-2007 03:28 AM

This test.sh script is the one I asked you to create right? Can you just verify what it contains?


All times are GMT -5. The time now is 07:37 PM.