LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-04-2007, 04:17 AM   #16
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,508

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957

Quote:
Originally Posted by yusufs View Post
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.

Last edited by colucix; 12-04-2007 at 04:24 AM. Reason: adding more info
 
Old 12-04-2007, 04:44 AM   #17
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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 View Post
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 View Post
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.

Last edited by matthewg42; 12-04-2007 at 04:44 AM. Reason: oop, double negative
 
Old 12-04-2007, 04:49 AM   #18
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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.
 
Old 12-04-2007, 06:06 AM   #19
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by matthewg42 View Post
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
 
Old 12-04-2007, 06:09 AM   #20
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by yusufs View Post
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
 
Old 12-04-2007, 06:40 AM   #21
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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.
 
Old 12-04-2007, 07:29 AM   #22
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by matthewg42 View Post
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
 
Old 12-04-2007, 07:37 AM   #23
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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
 
Old 12-04-2007, 03:13 PM   #24
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by matthewg42 View Post
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
 
Old 12-04-2007, 03:44 PM   #25
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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...
 
Old 12-04-2007, 05:07 PM   #26
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,289

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
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.
 
Old 12-05-2007, 01:11 AM   #27
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Quote:
Originally Posted by chrism01 View Post
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?
 
Old 12-05-2007, 01:31 AM   #28
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
[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
 
Old 12-05-2007, 03:19 AM   #29
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
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
 
Old 12-05-2007, 03:28 AM   #30
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

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


Reply

Tags
chmod, cron, grep, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U Suse/Novell 11 01-04-2007 01:57 AM
Cron not Executing PHP script Badnoodles Linux - General 2 10-25-2006 04:56 PM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 01:50 PM
Executing cron jobs on a w2k3 server using cygwin hq4ever General 4 06-01-2005 06:45 AM


All times are GMT -5. The time now is 03:08 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration