Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 9th July 2009, 13:09
Tezux Tezux is offline
Member
 
Join Date: Jun 2009
Posts: 38
Thanks: 0
Thanked 2 Times in 2 Posts
Default [SOLVED] Simple Cron Job - Need Help please

I am simply trying to get a cronjob to email my .txt file. That parts easy and works fine

The problem:

I want to change the From: and Subject: of the email so its says its from me instead of root

Heres my very simple Cronjob

MAILTO="me@example.com"

30 20 * * * /var/mytextfile.txt

Yeh thats all there is to it, it works fine but I just wanna know how to change it so it can do what I mentioned above. Doing this doesnt work:

FROM="you@example.com"
SUBJECT="My Text File"

Yeh Im a newbie at scripts. Im using Debain Lenny by the way

Any idea guys?

Last edited by Tezux; 10th July 2009 at 13:21. Reason: Problem Solved
Reply With Quote
Sponsored Links
  #2  
Old 9th July 2009, 15:30
Tezux Tezux is offline
Member
 
Join Date: Jun 2009
Posts: 38
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Ok im getting there slowly, this now gives me the subject i want to have

30 20 * * * /var/mytextfile.txt | mail -s "My Subject" me@example.com

So if only I could figure out the From Part

Any Geniuses out there know how? This Part really has me stumped. I want to say its from donotreply@example.com instead of root.
Reply With Quote
  #3  
Old 9th July 2009, 16:15
id10t id10t is offline
Senior Member
 
Join Date: Nov 2008
Posts: 242
Thanks: 2
Thanked 22 Times in 22 Posts
Default

Try sending your mail using mailm - it allows you to specify all that stuff. Works great.

http://www.sfr-fresh.com/unix/privat/mailm-0.3.tar.gz/
Reply With Quote
  #4  
Old 10th July 2009, 11:47
Tezux Tezux is offline
Member
 
Join Date: Jun 2009
Posts: 38
Thanks: 0
Thanked 2 Times in 2 Posts
Default

thanks, however mailm isn't working for me, am getting several errors when trying to install, it seems others are having the same problem as me but no solutions can be found.
I have just about got this cronjob working now so I would like to stick with it.

Anyone else can be of help?? Thanks for helping id10t
Reply With Quote
  #5  
Old 10th July 2009, 13:11
Tezux Tezux is offline
Member
 
Join Date: Jun 2009
Posts: 38
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Problem Solved.

All you need to do is create a different user and set a Password for the user.

click on SYSTEM / ADMINISTRATION / USERS AND GROUPS

Make the new user have the same username as your email address
and setup the Cron under this new user.

e.g. donotreply@example.com (Username would be donotreply)

Then if the Hostname is your domain name which you want it to be then the email the cronjob sends will look like its from that address

donotreply@example.com

So simple yet it took me ages to figure it out. I feel like an idiot. Anyway hope this helps anyone else trying to do the same thing with a Cronjob.

For newbies wondering how to become that new user, simply open a shell and type this:

"su donotreply" (donotreply being the new user you have created of course)
Enter Password and then type "crontab -e" and setup the cron as the new user.

To easy
Reply With Quote
  #6  
Old 10th July 2009, 13:26
Tezux Tezux is offline
Member
 
Join Date: Jun 2009
Posts: 38
Thanks: 0
Thanked 2 Times in 2 Posts
 
Default

How do you mark this thread as SOLVED?
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
webalizer cron job not running bolero Installation/Configuration 2 2nd June 2009 14:09
How to create a Cron job for ISPconfig AngelDrago HOWTO-Related Questions 1 13th January 2009 15:30
Cron job failure report torusturtle General 5 18th July 2008 15:13
wget cron job bschultz Programming/Scripts 9 12th September 2007 19:53
cron job modified after upgrading V 2.2.5 jfruano Installation/Configuration 1 21st July 2006 13:31


All times are GMT +2. The time now is 21:47.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.