Simple Cron Job - Need Help please

Discussion in 'Programming/Scripts' started by Tezux, Jul 9, 2009.

  1. Tezux

    Tezux New Member

    [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="[email protected]"

    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="[email protected]"
    SUBJECT="My Text File"

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

    Any idea guys?:rolleyes:
    Last edited: Jul 10, 2009
  2. Tezux

    Tezux New Member

  3. id10t

    id10t Member

  4. Tezux

    Tezux New Member

    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
  5. Tezux

    Tezux New Member

    Problem Solved.

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


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

    e.g. [email protected] (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

    [email protected]

    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:cool:
  6. Tezux

    Tezux New Member

    How do you mark this thread as SOLVED?

Share This Page