cron job running but not getting the email that should send
Hi all,
i am using a crontab to run a perl script. When i check the /var/log/cron, it shows that cron job ran successfully but i am not getting the output that the script should send. The same script runs successfully on a solaris server and sends output as email. Is there any other place to look for possible causes. Thanks in advance! Code:
# crontab -l |
Quote:
It's hard to say without seeing the script, but my guess is that this is dumping the script's email output to /dev/null or some other critical output the script generates while executing. It also might be an issue with your mail client. Does mail work for everything else? |
Hi brian-ocs,
I am afraid to post the script as it is having 2986 lines. I am hoping that the script should be good as it was working fine on another server. Yes, the mail client working fine as i am getting other emails from other cronjobs. |
Well, redirect stdout & stderr to a file (instead of /dev/null) and see what you get in it. Also note that cron generally emails either the cron job owner or root if it has a problem.
Also, given this is Perl, have you tried Code:
perl -wc report.pl (That cmd does a Perl 'compile' & syntax check without executing the program. ) |
Thank you Very much chrism01,
owner of the cronjob is root. Yes, redirecting output to a file showed that the script is executing successfully and giving the desired output. The only problem is, it somehow not sending this output as an email. BTW: Code:
# perl -wc report.pl |
Can you post the lines of the script that should be sending the mail and any associated "log" output?
|
This
Code:
..... > /dev/null 2>&1 Remove it and it should send an email with output. I have this part of the code at the end of "ntpdate .... " line in cron when NTP syncs the time and I don't want to receive emails about executing it! |
Hi catkin,
The following are some sections in the script related email. Code:
our %output = ( @lithos, Yes i tried removing > /dev/null 2>&1 but no luck. Not getting emailed. |
Quote:
|
The output contains 1542 lines and it is all about the results of commands used in the script.
Is there any way to know what are the emails sent by the server like to whom,when,subject etc ? |
Quote:
I'm no perl-spert, was just helping move the thread along by asking the right questions, but this looks wrong unless you have changed it to hide confidential information: Code:
recipients => 'myemail.mycompany.com' |
Code:
I'm no perl-spert, was just helping move the thread along by asking the right questions, but this looks wrong unless you have changed it to hide confidential information |
Hi all,
Now i know that redirecting the script's output to a file shows that script is running fine. Now is there a way to modify cronjob so that it can send the output file to my email . like Code:
00 07 * * * /usr/local/test/cron.d/report.pl > /output.txt Thanks in advance! |
Code:
00 07 * * * /usr/local/test/cron.d/report.pl |
If you just run it from the cmd line interactively, does it email you?
If yes, the its an env problem in cron; if no, its a general env /programming problem & you'll need to read the code/output to discover what. Re cron env, try 'perl -wc report.pl' in cron; redirect the stdout+stderr to a file as previously advised. |
All times are GMT -5. The time now is 01:13 PM. |