1748128 Members
3357 Online
108758 Solutions
New Discussion

crontab HP-UX

 
rdiaz
Frequent Advisor

crontab HP-UX

Hello every one,

 

My case is the following... I have configured my crontab for send email with aliases:

 

##

# Alias for mailer daemon
MAILER-DAEMON   : root
root    : l-sistemas.cron.ced@mydomain.com

# RFC 822 requires that every host have a mail address "postmaster"
postmaster      : root

# Aliases to handle mail to msgs and news
nobody          : /dev/null

# System Admistration aliases
operator        : root
uucp            : root
daemon          : root

# Ftp maintainer.
ftp-bugs        : root

# Local aliases

 

- When I make a cron job, I receive TWO emails, when I have only one with a subjets, let me show you my job in crontab:

 

40 4 * * * /export/backup/programas/sv0011/PortalAverroes-backup-NETBACKUP.sh | mailx -s "PortalAverroes-backup-NETBACKUP" root >/dev/null 2>&1

 

- Like you see, I want receive the output of the script "PortalAverroes"; in fact I receive this, but twice:

 

First email with subject like I want: "PortalAverroes-backup-NETBACKUP"

 

Second email with subject like i dont want: "[l-sistemas.cron.ced@mydomain.com] cron"

 

Do you know how resolv this condition??

 

In fact I tried place a { >/dev/null 2>&1 } condition, but in the body of the email of "cron" I receive the output like this:

 

*************************************************
Cron: El mensaje anterior es la salida estándar
      y el error estándar de uno de sus comandos crontab:

/export/backup/programas/puck/salva-NETBACKUP.sh | mailx -s "Archivado de archivelog oracle y wal postgresql" root >/dev/null 2>&1

 

Thanks a lot.

 

 

2 REPLIES 2
Dennis Handly
Acclaimed Contributor

Re: cron sending mail

>When I make a cron job, I receive TWO emails

 

You have two commands in your pipeline.  With 4 outputs and one of those is sent as stdin to mailx(1).

You are handling the stdout/stderr for mailx but not stderr for your script.

So you either need to redirect or duplicate it:

PortalAverroes-backup-NETBACKUP.sh 2>&1 | mailx -s "PortalAverroes-backup-NETBACKUP" root >/dev/null 2>&1

 

So it is cron(1m) that is sending that second mail, which would be more obvious to everyone if the message was in English.

rdiaz
Frequent Advisor

Re: cron sending mail

This works!

 

Thanks!