Mailing the output of a command run from cron

Tom Reingold tr at samadams.princeton.edu
Tue Apr 16 07:59:36 AEST 1991


In article <1031 at lucifer.UUCP> rst at lucifer.UUCP ( 233) writes:

$ I am trying to get cron to mail me the standard output and standard error of
$ regularly run commands. I have an entry that looks like this:-
$ 
$ /usr/local/etc/crontab/evening |& mail -s "Evening cleanup" sysadmin
$ 
$ I know the command is being executed, but the mail is never sent. Any ideas?

If you use the cron in the att universe, you will get this
automatically.  Not only that, ordinary users can use cron in the att
universe.  They must (and the superuser ought to) use the "crontab"
command for updating their personal crontab files.

Now if you still want to do it your way, try
	
	command 2>&1 | mail -s "subject" sysadmin

This is Bourne shell syntax.  The "2>&1" means send output destined for
file descriptor 2 to where output for fd 1 is going.
--
        Tom Reingold
        tr at samadams.princeton.edu  OR  ...!princeton!samadams!tr
        "Warning: Do not drive with Auto-Shade in place.  Remove
        from windshield before starting ignition."



More information about the Comp.sys.pyramid mailing list