Another mailx question

I have a script that runs every night that is supposed to send a log file to a list of email addresses. When I run this command from the command prompt, it works successfully:

mailx -s "Filename to send" "`cat email.address`" < $outfile

The email.address file contains the list of email addresses.

When this script runs each night, however, I do not receive the email or any error message. Is there a way to check to see what is happening in the cron submitted script each night? I checked "mail" but is says I have no mail.

Appreciate any help.

Try this

while read line
do
mailx -s "Filename to send" $line < $outfile
done < email.address

regards,
Ahamed

I have another wrinkle to add. I create a test script with your code and it works. Thanks for that. I also ran it with my code and it works as well when run manually.

It looks like the problem is with the cron job that runs. When the cron scheduled script processes, the note does not get sent. Is there something in cron that would keep it from sending this note? Something in the way cron submits the script?

You can probably redirect the output to a log file and check if there are any errors.

Also check for which user you have setup the cronjob and if that user is having necessary permission to execute the script.

regards,
Ahamed

Use full paths to files being used inside code e.g.
/path/to/email.address, full path to $outfile etc. and it should work fine.

If it doesnt run put the script in cron like (ofcourse, put your execution times..)

* * * * *  script.sh 2>>/path/log.err 1>>/path/log.log

Regards.