How to set Subject in Sendmail in Crontab


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to set Subject in Sendmail in Crontab
# 1  
Old 12-10-2010
Question How to set Subject in Sendmail in Crontab

Hello All,

I am trying to send a file through email everyday from one of my Linux (x86_64) system. I've scheduled Sendmail in Crontab like this-

00 8 * * * /usr/sbin/sendmail name@xxx.co.uk < /home/file1.out

This entry in crontab is working very fine and I am receiving file file1.out each and everyday sharp at 8 AM through email. But the subject line is blank. I am trying a lot but not being able to set the subject line.

Please let me know if you have any idea, how to set subject line in sendmail in Crontab. Subject should come like- "Row count for today: <Current Date>"

Thanks in Advance !!
Naresh
# 2  
Old 12-10-2010
Code:
set `wc -l /home/file1.out`
00 8 * * * /usr/sbin/mailx -s "Row count : $1" name@xxx.co.uk < /home/file1.out


Last edited by R0H0N; 12-10-2010 at 02:52 AM.. Reason: added code tags
R0H0N
# 3  
Old 12-10-2010
No it's not working. :-( Is there any way to set subject in Sendmail?
# 4  
Old 12-10-2010
Code:
00 8 * * * echo "Subject: Testing" | cat - /home/file1.out | /usr/sbin/sendmail -t name@xxx.co.uk

R0H0N
# 5  
Old 12-10-2010
Thanks a lot dear, it worked this time. :-)

---------- Post updated at 02:37 PM ---------- Previous update was at 02:33 PM ----------

Just have another doubt, if I want to specify current date in subject, then how to do that?
# 6  
Old 12-10-2010
Quote:
Originally Posted by R0H0N
Code:
00 8 * * * echo "Subject: Testing" | cat - /home/file1.out | /usr/sbin/sendmail -t name@xxx.co.uk


Code:
00 8 * * * date '+%d-%b-%Y@+%H:%M:%S' | cat - /home/file1.out | /usr/sbin/sendmail -t name@xxx.co.uk

The above command will display date and time in subject line.(E.g. 23-11-2010@22:12:45)

Read man pages for date command if u want to display any specific values in subject line.
R0H0N
# 7  
Old 12-10-2010
It's ok, but I wanted it along with Subject. How to set that with subject like-

"Subject: Testing for (today's date)"
"Subject: Testing for 20101012"
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to Set crontab for 4th and 25th of every month?

Hello, I wanted to set Crontab for 4th and 25th of every month at 5:00 PM. Script should take previous month and current year as command line arguement like... /home/test1.sh -f ABCD 03 2014 so above script will run on 4th and 25th April 2014 but argument should be like previous month... (11 Replies)
Discussion started by: ajju
11 Replies

2. AIX

Set email Priority using sendmail

Hi everyone, I'm trying to send an email on unix using sendmail command. For setting the priority to high I use: X-Priority: 1 And it works on HP but when I tried it on AIX the email is sent but no priority!! Anyone can help me Thanks in advance, Hiposh (3 Replies)
Discussion started by: hiposh
3 Replies

3. 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

4. Solaris

mailx/sendmail configuration/set up problem

Hello Good People of Linux World!!! Background: Recent Networking Graduate, thrown in line of fire. For the past couple of days I have been searching online for answers and haven't gotten anywhere regarding Mailx, Sendmail functionality on SunOS 5.9. My dilemma: Mailx / sendmail are... (28 Replies)
Discussion started by: kazmiM
28 Replies

5. Red Hat

Set up Sendmail as sending only server

I have set up where my primary fibre optical WAN access does not have any sending SMTP service but my fall-back ADSL service does. However, with most Internet Service Providers, the SMTP service access is "locked" to the IP addresses that the service knows about. Therefore I can not send SMTP... (0 Replies)
Discussion started by: smlunatick
0 Replies

6. Shell Programming and Scripting

How to set crontab for different Time Zone

Hi, I want to set cron job for different time zone from my machine. So here is what I did to set it. I am having a file cronfile, which I use to set cron jobs by using Crontab cronfile Now in cronfile I set TZ variable as Set TZ=Asia/Calcutta But now... (3 Replies)
Discussion started by: sarbjit
3 Replies

7. Shell Programming and Scripting

Unable to populate subject field of the email while using sendmail

Hi, Can anyone kindly provide some information about how to populate the subject field of the email while using the sendmail utility ? Itried the following command line argument : echo -e "Body of the email" | /usr/lib/sendmail -f from@from.com -t to@to.com -s " Subject of the email" ... (4 Replies)
Discussion started by: sdiptanil
4 Replies

8. UNIX for Dummies Questions & Answers

How to set HIGH importance to a mail sent through mailx or sendmail command

I have written a script for sending automated email, reporting the running status of a cron scheduled work. Now, the issue is, my Project Manager wants, the mail should be received with HIGH IMPORTANCE. How can I do that, kindly anybody explain. Thank you so much. (3 Replies)
Discussion started by: mitte_dino
3 Replies

9. Shell Programming and Scripting

sendmail subject

what is the syntax for sending a subject ? sendmail -t a@b.com The person receives the mail with an empty subject! the man pages dont give anything related to subject...anybody?? (11 Replies)
Discussion started by: wannalearn
11 Replies

10. Shell Programming and Scripting

sendmail subject to append dynamically.

Hi, I have to use sendmail from command line, and we need to append a static string in subject to a new value from file.Is there any way to do it. Thanks Shrikrishna (1 Reply)
Discussion started by: shrikrishna
1 Replies
Login or Register to Ask a Question