[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Exploring the possibilities of cron



Brent Harding wrote:
> How would cron do something such as, emailing 	a file once and awhile, make
> the file empty, and wait until the next run, but not mail anything if it's
> empty. I've never done much with emailing besides piping echo to mail, but
> it's limited to one line.

What I would do is put all of the work into a shell script, and have cron
call the shell script.  Just off the top of my head, something like:

#!/bin/sh
if [ -s /path/to/file ]
  mail -s Here's_the_file email_address@isp.com < /path/to/file
  rm -f /path/to/file
  touch /path/to/file
fi

Warning: This has not been tested.  I'm sure there are better ways to do it. 
This is just a *very* rough example of generally how to go about such a
thing.  I'm sure there are better ways to do it.  The rm and touch lines
might be combinable into something like "echo "" > /path/to/file" but I'm
not sure.  I'm sure there are better ways to do it.
-- 
Mike Werner  KA8YSD   | He that is slow to believe anything and
                      | everything is of great understanding,
'91 GS500E            | for belief in one false principle is the
Morgantown WV         | beginning of all unwisdom.



Reply to: