Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send mail once a week 1

Status
Not open for further replies.

cleanair4me46

Technical User
Feb 3, 2009
41
US
I am using Solaris 10 and its been along time but I remember creating a korn shell script to send an email message once a week. Problem is I forgot how to do all of that.

Would this be the right direction in a file called Sender?
Code:
mailx -s "Reminder Message" "joe.smith@email.adres, ed.jones@emailer.com, joe.clarke@email.com" << EOF
Do your work 
reminder message.
EOF

As I recall I need to create a cron job.
How would the cron look? My attempt using my name (Jenkins) is below
0 2 * * wed Jenkins Sender

This would run at 2 PM every Wednesday
 
crontab -e

0 2 * * wed /home/Jenkins/bin/Sender

This is a full path to the executable
assuming home for Jenkins is /home/Jenkins

Use full path in your executable

cat Sender

/usr/bin/mailx -s "Reminder Message" "joe.smith@email.adres, ed.jones@emailer.com, joe.clarke@email.com" << EOF
Do your work
reminder message.
EOF


A great teacher, does not provide answers, but methods to teach others "How and where to find the answers"

bsh

35 years Bell, AT&T, Lucent, Avaya
Tier 3 for 25 years and counting
 
According to the man pages (man crontab) the first 5 fields of the crontab line should be integer patterns.

So:
0 2 * * wed Jenkins Sender
is going to produce errors (and run at 02:00 , ie AM)

Try:
0 14 * * 3 /home/Jenkins/bin/Sender

Additionally, I have seen crontabs 'wiped' when using crontab -e. A more lenghty (but safer) construct is:
crontab -l /tmp/cron.txt
vi /tmp/cron.txt
crontab /tmp/cron.txt

When I have used mailx I have supplied a 'space' separated list of addressees, un-quoted:

mailx -s "<subject>" a.name@email.com b.name@email.com


I hope that helps.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top