- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- cron keeps sending mail to root
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2005 11:26 AM
06-17-2005 11:26 AM
i have 2 questions Please help!
the script below run every minute to check for a deamon.
every time it run, it send mail to root.
How can i stop it from sending mail to root just for this job. because i have many jobs running and need cron report.
2-someone please let me know how to append to a file whenever the argument #2 is true.
Regards,
Tom
#!/usr/bin/sh
# This script will check for Cognos every 30 seconds
# and if Cognos daemon is not available. It will restart
NAME=`ps -ef |grep [l]icense1 | awk '{print $8}'`
if [ "cognos1d" = "$NAME" ]
then
echo "License Manager is already running \n"
# mailx -r root@sunuxdev -s "Checking Cognos license manager `uname -n` `date`"
tquach@sunrider.com < /util/run/cognosr
exit 0
else
/opt/cognos/license1/lmgrd
mailx -r root@sunuxdev -s "Checking Cognos license manager`uname -n` `date`" tqu
ach@sunrider.com < /util/run/cognoss
fi
~
~
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2005 11:31 AM
06-17-2005 11:31 AM
Re: cron keeps sending mail to root
You will see a | mailx -s with an email address.
You need to take that part of the cron command line out and root will stop getting the mail.
Or
Looking at your code comment out hte line htat says mailx -r
mailx is the program being used to send the mail.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2005 03:43 PM
06-17-2005 03:43 PM
Re: cron keeps sending mail to root
I agree, comment out this line:
mailx -r root@sunuxdev -s "Checking Cognos license manager`uname -n` `date`" tqu
with a hash, we call it, "#" or
#mailx -r root@sunuxdev -s "Checking Cognos license manager`uname -n` `date`" tqu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2005 04:37 PM
06-17-2005 04:37 PM
Solutionthe output from cron gets mailed to the owner of the process, or the person specified in the MAILTO variable, but what if you don't want that? If you want to mail the output to someone else, you can
just pipe the output to the command mail.
e.g.
* 12 10,12,14,16 * * root backup.sh | mail -s "Subject of mail" user
If you wish to mail the output to someone not located on the machine, in the
above example, substitute user for the email address of the person who
wishes to receive the output.
If you have a command that is run often, and you don't want to be emailed
the output every time, you can redirect the output to a log file (or /dev/null, if you really don't want the output).
e,g
* 12 10,12,14,16 * * root backup.sh >> log.file
Notice we're using two > signs so that the output appends the log file and
doesn't clobber previous output.
The above example only redirects the standard output, not the standard error,
if you want all output stored in the log file, this should do the trick:
* 12 10,12,14,16 * * root backup.sh >> logfile 2>&1
You can then set up a cron job that mails you the contents of the file at
specified time intervals, using the cmd:
mail -s "logfile for cmd"
thanks
Devesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2005 10:19 PM
06-17-2005 10:19 PM
Re: cron keeps sending mail to root
your script mails to root because it is run from root's crontab and produces some kind of output to std. out/std. error, which it cannot write elsewhere, e.g. "echo Licence Manager..".
Apart from the above mentioned possibilities you can change and test your script on the command line until it produces no output, or take care in the crontab that std. err and std. out are redirected, e.g. like this:
* * * * * /usr/local/bin/check_cognos.sh >/tmp/check_cognos.out 2>&1
The above should be on a single line and will prevent mailing to root.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2005 01:08 AM
06-18-2005 01:08 AM
Re: cron keeps sending mail to root
* * * * * /path_to_script/your_script 1>/dev/null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2005 07:18 PM
06-18-2005 07:18 PM
Re: cron keeps sending mail to root
0-59 * * * * /util/run/startcognos.sh > /dev/null 2>&1
this one works fine, but it will send all output to null
what if i just want this condition to send out mail to me only. is it possible?
else
/opt/cognos/license1/lmgrd
mailx -r root@sunuxdev -s "Checking Cognos license manager`uname -n` `date`" tqu
ach@sunrider.com < /util/run/cognoss
Thanks,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2005 08:29 AM
06-19-2005 08:29 AM
Re: cron keeps sending mail to root
keep the "/dev/null if you like, but redirect the output to a temp-file, then you can do an email.. to you using the
temp-file as email to you.
ex.
# reset temp file to zero bytes
> /tmp/tom.tempfile
if [ "cognos1d" = "$NAME" ]
then
# append to the temp file by >>
echo " `date` " >> /tmp/tom.tempfile
echo "Lic Mgr.." >> /tmp/tom.tempfile
else
# start the lic mgr up
/opt/cognos/license1/lmgrd
RET=$?
echo "lmgrd ret=$RET" >> /tmp/tom.tempfile
fi
# now send the mail to myself
# only send the tom.tempfile
mailx -s "Checking Cognos license manager`uname -n` `date`" tach@sunrider.com < /tmp/tom.tempfile
# you can add more echo to the temp.file
# thought the return code $RET is important
# so tract this to the temp-file.