cron job and sendmail

now stick with me while i show you just how much of a noob i am with linux lol.

i would like to set up a cron job to send out an email every month to a group of people on our network, this email is to be used to bug people to send me updates for the website i manage. however i have no idea where to start writing a cron job, i have webmin installed and if possible would like instructions on how to set up the cron job using webmin, the email package i have installed is sendmail.

can anyone point me in the right direction?
3 answers Last reply
More about cron sendmail
  1. On Ubuntu Applications -> Accessories -> Terminal

    On Fedora / CentOS / RedHat Applications -> System Tools -> Terminal

    Ubuntu

    
    
    sudo su -
    
    crontab -e
    
    



    Fedora / CentOS / RedHat / etc


    
    
    su -
    
    crontab -e
    
    


    
    
    5 0 * * * /root/send_email >> $HOME/tmp/out 2>&1
    
    



    /root/send_email

    
    #!/bin/bash
    
    recipients="user0@domain.co.uk user1@domain.co.uk user2@domain.com.uk"
    
    cat /root/email_message | /bin/mail $recipients
    
    


    /root/email_message is the message you want to send

    this is just an example

    make sure you chmod u+rx /root/send_email


    The time and date fields are:

    field allowed values
    ----- --------------
    minute 0-59
    hour 0-23
    day of month 1-31
    month 1-12 (or names, see below)
    day of week 0-7 (0 or 7 is Sun, or use names)

    A field may be an asterisk (*), which always stands for "first-last".

    Ranges of numbers are allowed. Ranges are two numbers separated with a
    hyphen. The specified range is inclusive. For example, 8-11 for an
    "hours" entry specifies execution at hours 8, 9, 10 and 11.

    Lists are allowed. A list is a set of numbers (or ranges) separated by
    commas. Examples: "1,2,5,9", "0-4,8-12".

    EXAMPLE CRON FILE
    # use /bin/sh to run commands, no matter what /etc/passwd says
    SHELL=/bin/sh
    # mail any output to ‘paul’, no matter whose crontab this is
    MAILTO=paul
    #
    # run five minutes after midnight, every day
    5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
    # run at 2:15pm on the first of every month -- output mailed to paul
    15 14 1 * * $HOME/bin/monthly
    # run at 10 pm on weekdays, annoy Joe
    0 22 * * 1-5 mail -s "It’s 10pm" joe%Joe,%%Where are your kids?%
    23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
    5 4 * * sun echo "run at 5 after 4 every sunday"


    http://tldp.org/LDP/lame/LAME/linux-admin-made-easy/using-cron.html


    Good luck :)
  2. thats alot of info cheers again linux_0, ill let you know how i get on, you are the unsung hero of the linux section :)
  3. Ah, reminds me of a setup I had to automatically remind people to pick up a bakery order every Wednesday for an on-campus event, rotating through a list of volunteers.
Ask a new question

Read More

Email Sendmail