Monday, November 23, 2009

[nslu2-linux] Re: [openslug] Send mail with nail in crontab

 

I found a solution to bypass my problem thanks to tips of Marc and Roland.
1)My script worked in shell with user1 but not in crontab.
2)crontab is run by root.
3)When I used "su -" and excute the script I have the same error as in crontab:
"
/usr/lib/sendmail: No such file or directory
. . . message not sent.
"
4)So I added "/bin/su user1 -c" to my script :
33 23 * * * /bin/su user1 -c '/opt/bin/bash /temp/testmail/send_mail.sh'

And this is OK now !

5)I choose that way because I've got a bad feeling that "nail" checks for the user (root or not root) and use sendmail !!!!

If someone understand what's happen, I am very interesting to know...

Thank You

T-Kayna

--- In nslu2-linux@yahoogroups.com, "tkayna" <tkayna@...> wrote:
>
> Hello,
>
> I made un script to send mail.
> My script works executing in shell but not in crontab.
> I also add full path for binaries but it's the same.
>
> Can someone help me ?
>
> ***BASH SCRIPT send_mail.sh :
>
> #!/opt/bin/bash
>
> nail='/usr/bin/nail'
> sleep='/bin/sleep'
> echo='/bin/echo'
>
>
> function mail_status ()
> {
> ${sleep} 1
> ${echo} $1 $2 | ${nail} -s "save_sites_SQL_$1_$2" myemail@...;
> #echo $? > /tmp/testestest_sendmail.txt
> }
>
> #### DEBUG TESTS ####
>
> mail_status "Test" "succes";
>
> ***CRONTAB LINE :
>
> 33 23 * * * /opt/bin/bash /temp/testmail/send_mail.sh
>

__._,_.___
.

__,_._,___

No comments:

Post a Comment