Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Mar 2003 18:49:48 +0200
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Kenzo <kenzo_chin@hotmail.com>
Cc:        freebsd-questions@FreeBSD.org
Subject:   Re: cron question
Message-ID:  <20030315164948.GD20526@gothmog.gr>
In-Reply-To: <DAV69mLAztxc1o8yfog0000008c@hotmail.com>
References:  <DAV69mLAztxc1o8yfog0000008c@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2003-03-14 16:08, Kenzo <kenzo_chin@hotmail.com> wrote:
> I'm trying to automatically create a report in cron and E-mailling it to my
> E-mail account.
>
> this is what I have.
>
> 0 1 0 0 0 root /usr/bin/perl /usr/local/bin/spamstat.pl /var/log/maillog.0 >
> /var/log/spam_report | uuencode spam_report spam_report | mail -s
> "spam_daily_report" me@mydomain.com

What is 0 1 0 0 0 supposed to do?  I am inclined to think you have the
time information on that crontab line all wrong.

You're redirecting all output from spamstat.pl to the file
/var/log/spam_report.  Nothing goes down the pipe to uuencode.

> what I get is a blanc attachment.
> the spam_report file does get created in the /var/log dir with all the right
> stuff in it, so I don't get why it won't E-mail it.
> I have the same setup for another report and it works fine.
>
> I know this would probably work better if I created a script to do all this
> and have cron run the script, but I don't know how to write any scripts.

Just put the commands in /root/spam_report.sh and chmod 755 it.A
Try this script:

	#!/bin/sh

	/usr/bin/perl /usr/local/bin/spamstat.pl /var/log/maillog.0 | \
	uuencode spam_report | \
	mail -s "spam_daily_report" me@mydomain.com

Then you can make this executable with:

	# chmod u+x /root/spam_report.sh

and call it from /etc/crontab as:

	0   1   *   *   *   root   /root/spam_report.sh

That should work fine :)

- Giorgos


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030315164948.GD20526>