Sign in with
Sign up | Sign in
Your question

cron job and sendmail

Last response: in Linux/Free BSD
October 21, 2008 9:16:54 AM

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?

More about : cron job sendmail

October 21, 2008 9:47:15 AM

On Ubuntu Applications -> Accessories -> Terminal

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


  1. sudo su -
  3. crontab -e

Fedora / CentOS / RedHat / etc

  1. su -
  3. crontab -e

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


  1. #!/bin/bash
  3. recipients=""
  5. 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".

# use /bin/sh to run commands, no matter what /etc/passwd says
# mail any output to ‘paul’, no matter whose crontab this is
# 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"

Good luck :) 
October 21, 2008 10:02:25 AM

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 :) 
November 4, 2008 1:41:33 AM

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.
Related resources