1833012 Members
2852 Online
110048 Solutions
New Discussion

Sendmail from cron

 
jason thompson_1
Frequent Advisor

Sendmail from cron

Users and root can use sendmail to send an attachment from the command line but when the same command is executed from cron it fails. The cron environment is the same as the users.
What's that smell?
5 REPLIES 5
Mark Greene_1
Honored Contributor

Re: Sendmail from cron

You have to remember that cron does not run the .profile or any other "." environment files, so things like paths and environment variables may need to be specifically set-up for the cron process in question.

Also, background processes run without a tty, so any command that expects to be interacting with a terminal won't be, and will fail.

How are they trying to do the attachments?

mark
the future will be a lot like now, only later
Sanjay_6
Honored Contributor

Re: Sendmail from cron

Hi,

Are you using the absolute path for the commands. That may be the problem since cron does not source the .profile for the login ids. you can ask it to source the .profile, by adding ". /home_dir/.profile;" in the command line.

hope this helps.

Regds
jason thompson_1
Frequent Advisor

Re: Sendmail from cron

The environment is set within cron to the same parameters that the users use. The actual command is (echo "Subject: Test List"; echo "From: Sales"; echo "To: user@domain.com"; echo "Your group list is attached to this email." ; uuencode /PATH TO FILE/FILE.DBF ) | /usr/sbin/sendmail user@domain.com
What's that smell?
Mark Greene_1
Honored Contributor

Re: Sendmail from cron

You cannot use echo, it expects a tty on the other side of stdout; try print instead. You may need to put all that into a script so you can specify ksh as the shell environment to get print to go.

mark
the future will be a lot like now, only later
Steven E. Protter
Exalted Contributor

Re: Sendmail from cron

The attached script is in use with my cron system.

I don not believe there are any environment requirements since full path is supposed to be used in this script.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com