Issues with cronjob : Script using sendmail


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Issues with cronjob : Script using sendmail
# 8  
Old 06-04-2009
This line is a syntax error:
Quote:
SUBJECT="Log Report Generated on "`date +%d-%m-%Y`"
This variable is not defined:
Code:
echo From: "$machineName" >> yy


Are you sure that that you are executing the same script from cron as the one from the command prompt? The script as posted will give syntax errors. Any errors from the cron version will be in the unix mailbox of the user who owns the cron.

-----Post Update-----

After a bit of checking, many of the lines you are giving to "sendmail" are not needed. The workfiles are also not needed. The echo "." line is to terminate the input to sendmail - some systems need it.
The script can be boiled down to:

Code:
echo "Sending email..."
RECIPIENTS="testadmin@info.com"
(
echo "To: ${RECIPIENTS}" 
echo "From: `uname -n`" 
echo "Subject: Log Report Generated on `date +%d-%m-%Y`" 
echo ""
echo "Log report"
echo ""
ls -1tr /home/testadmin/testdir/test.log* 2>/dev/null | tail -1
echo "."
) | /usr/lib/sendmail "${RECIPIENTS}"

echo "Done!"


Last edited by methyl; 06-04-2009 at 11:59 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sendmail with HTML body and attachment code issues

Hi, I was working on getting an HTML file in the mail body along with attaching a "csv" file to the mail. Below are the 2 parts of the code. I need help with the second part where I'm sending the mail. The HTML file as an attachment is perfect without any issues and with proper formatting.... (6 Replies)
Discussion started by: aster007
6 Replies

2. UNIX for Dummies Questions & Answers

Sendmail issues

Hi, I'm having some problems with sendmail in Linux. The thing is when I type the following command to send an e-mail: sendmail bartoszk@companydomain.pl< test.txt it looks like it executed but I don't receive the mail. The file test.txt looks like that: To:... (3 Replies)
Discussion started by: bartoszk
3 Replies

3. UNIX for Dummies Questions & Answers

Having some issues with cronjob

Hi, i have a cronjob scheduled to run daily at 7AM , the job which i am executing has three other scripts in it to execute. The first scripts gets executed perfectly but the 2nd and 3rd scripts which take 4-5 mins to complete does not executes,is there anything that i am missing. This is... (3 Replies)
Discussion started by: vikatakavi
3 Replies

4. Shell Programming and Scripting

Shell script with cronjob

Hello All, I have a script which will cd into a directory based on current timestamp. It will then do a grep and search for a condition. It's run on a cron job that runs every 30 minutes. So if it finds a match in 00, it sends out the contents of that grep to an alert and emails out. Now... (3 Replies)
Discussion started by: liketheshell
3 Replies

5. UNIX for Dummies Questions & Answers

nLocal sendmail issues when hostname not set in official domain name

Hi, I'm having issues with sendmail when I try to send host to host mail. I've had to change the "my official domain name" line to mycompany.com to get the mails through the external spam filter, when a mail was sent with hostname.mycompany.com it was blocked. I had to change the Dj macro... (0 Replies)
Discussion started by: elcounto
0 Replies

6. UNIX for Dummies Questions & Answers

Facing issues while running a cronjob !

Hi, I am trying to run a cronjob. But while doing so I am getting the following error message :- can't open yourfile in /var/spool/cron/crontabs directory. No such file or directory How can I resolve this issue ? Please help. Thanks Please view this code tag video for... (14 Replies)
Discussion started by: acidburn_007
14 Replies

7. UNIX for Dummies Questions & Answers

Script not running through Cronjob

Hi, I have a .ksh script which updates the database. The script is running fine manually but it is not running through cron.All the file permissions are fine. The script contents are as below: #!/usr/bin/ksh ddate=`date +%Y%m%d` echo $ddate nohup sqlplus crm/crm @db_state_sync.sql >>... (3 Replies)
Discussion started by: shivangi
3 Replies

8. UNIX for Dummies Questions & Answers

how to cancel a cronjob if the cronjob still running

hi everyone I'm newbie in this forum hope I can get some help here :) I have a command in crontab that executed every 1 minute sometime this command need more than 1 minute to finish the problem is, the crontab execute this command although it's not finish processing yet and causing the system... (7 Replies)
Discussion started by: 2j4h
7 Replies

9. Solaris

Creating a CronJob Script

Hi All, Good Day. Anyone can guide me on how to create a cronjob script that run prstat -a and vmstat 10 10 on the certain time of the day and produce a log which will be kept in a specific directory? I am running on Solaris 10. Thanks. (2 Replies)
Discussion started by: ronny_nch
2 Replies

10. Shell Programming and Scripting

cronjob inside the script

Hiii, can nayone provide me the sample script which can do the following tasks--- I will apperciate if anyone give me their valuable inputs.I guess this is not at all a big task for the experts in the forum so kindly help me out in this. (3 Replies)
Discussion started by: namishtiwari
3 Replies
Login or Register to Ask a Question