LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-19-2012, 02:12 AM   #1
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,141

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Smile cron log


hi guys, how to check cron logs whether the command run success fully or not?
 
Old 04-19-2012, 02:15 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,692

Rep: Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274
usually the user will get a mail about the output generated by the job (including stderr). Otherwise you have to modify your script to generate log.
 
Old 04-24-2012, 03:51 AM   #3
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,141

Original Poster
Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
if let's say had run this command:

less /var/log/messages | grep cron

and the crontab was scheduled to run at 3am everyday, the log messages should also display 3am? or what time it should display?

thanks.
 
Old 04-24-2012, 03:55 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,692

Rep: Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274
no, that will not work, crontab will not write anything in /var/log/messages.
the user can check his mails, in case of error cron will try to send the error message. Otherwise you need to implement some logging:

* * * * * /this/is/my/srcipt > /tmp/cron.script.log 2>/tmp/cron.script.log2

also you can add echo "message" > /tmp/some/log/file into the script and you can see what's happening
you can start your script with set -x.
 
Old 04-24-2012, 05:35 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Command line options when starting Dillon's cron (a.k.a. dcron) daemon can generate log messages at various levels including info. It can similarly be made to log to a named log file.

IDK about Vixie (a.k.a ISC) cron.

The bottom of the cron (or crond) man page usually states which of the two cron versions it applies to.
 
Old 04-24-2012, 11:03 PM   #6
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,141

Original Poster
Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi guys, thanks for your replies.

I had this on my crontab but it's not sending mail:

MAILTO="myemail@mine.com"
0 3 * * 1-5 find /home/mybackupfolder -depth | cpio --create --format=crc > /dev/st0

any ideas why it's not sending?

Thanks.
 
Old 04-24-2012, 11:30 PM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by JJJCR View Post
any ideas why it's not sending?
There's no stdout or stderr from the job?
There's no working MTA to send the mail?
 
Old 04-25-2012, 03:54 AM   #8
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,141

Original Poster
Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Question

Quote:
Originally Posted by catkin View Post
There's no stdout or stderr from the job?
There's no working MTA to send the mail?
hi catkin, thanks for the reply.

but if i used mail -s "Subject:Test" myemail@mytestmail.com
my message
.
EOT

i will be able to receive the email, is my crontab settings correct on my post above.

thanks.
 
Old 04-25-2012, 04:07 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,692

Rep: Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274
this is not the crontab, but the mail settings
you can write a test crontab like (adjust time):
12 12 * * * echo asdfasdf
and see if you get a mail
 
Old 04-26-2012, 08:59 PM   #10
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,141

Original Poster
Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
hi pan64, i got it already i just modified the crontab and i'm able to get the mail.

0 3 * * 1-5 tar -czf /dev/st0 /home/mybackupfolder | mail -s "Success" myemail@mybackup.com

thanks for all your help guys
 
  


Reply


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What the %$#@ is pam_unix (cron:session) doing every ten minutes? (/var/log/auth.log) CoffeeKing!!! Linux - Security 3 02-05-2009 07:07 AM
cron log graziano1968 Linux - General 4 01-23-2008 06:32 AM
Cron log hkillen Linux - Newbie 3 09-20-2006 09:44 AM
Can't get Cron to log anything t3___ Linux - Newbie 3 05-19-2004 10:14 AM
dual entries in cron log for cron.daily cpharvey Linux - General 3 02-27-2003 02:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:55 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration