LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cron log (https://www.linuxquestions.org/questions/linux-general-1/cron-log-940594/)

JJJCR 04-19-2012 02:12 AM

cron log
 
hi guys, how to check cron logs whether the command run success fully or not?

pan64 04-19-2012 02:15 AM

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.

JJJCR 04-24-2012 03:51 AM

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.

pan64 04-24-2012 03:55 AM

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.

catkin 04-24-2012 05:35 AM

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.

JJJCR 04-24-2012 11:03 PM

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.

catkin 04-24-2012 11:30 PM

Quote:

Originally Posted by JJJCR (Post 4662317)
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?

JJJCR 04-25-2012 03:54 AM

Quote:

Originally Posted by catkin (Post 4662322)
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.

pan64 04-25-2012 04:07 AM

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

JJJCR 04-26-2012 08:59 PM

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 :)


All times are GMT -5. The time now is 01:07 AM.