Closed rikhtehgaran closed 8 years ago
It could be a path issue. Use absolute paths in your mymail script. It appears that the script bailed out and did not call mailsend or exited before calling mailsend. I created a mymail script as shown below, set it up the way your did in an ubuntu system and it works fine as expected. Thanks.
# cat /etc/init.d/mymail
#!/bin/sh
# muquit@muquit.com Mar-23-2016
MAILSEND="/usr/local/bin/mailsend"
LOG_FILE="/var/log/mymail.log"
RUNLEVEL=`/sbin/runlevel`
DATE=`/bin/date`
echo "${DATE} starts-- ">> ${LOG_FILE}
echo "Run level: ${RUNLEVEL}" >> ${LOG_FILE}
${MAILSEND} -V >> ${LOG_FILE} 2>&1
echo "${DATE} ends-- ">> ${LOG_FILE}
After reboot:
# cat /var/log/mymail.log
Wed Mar 23 16:33:49 EDT 2016 starts--
Run level: 2 6
mailsend Version: @(#) mailsend v1.18
Compiled with OpenSSL: OpenSSL 1.0.1c 10 May 2012
Wed Mar 23 16:33:49 EDT 2016 ends--
Wed Mar 23 16:34:41 EDT 2016 starts--
Run level: N 2
mailsend Version: @(#) mailsend v1.18
Compiled with OpenSSL: OpenSSL 1.0.1c 10 May 2012
Wed Mar 23 16:34:41 EDT 2016 ends--
Thanks it worked
i want to mail some log from server so i use mailsend in script and put in rc run levels for when boot email could be send. so i did these steps: Put mailsend script
Test it. it works and i get email
Also in log:
Now run this:
Remove log and reboot and im waiting for receive email
so no email and no log after reboot: