UNIX & Linux Forums

UNIX & Linux Forums (https://www.unix.com/index.php)
-   UNIX for Dummies Questions & Answers (https://www.unix.com/unix-for-dummies-questions-and-answers/)
-   -   How to check mailx on unix? (https://www.unix.com/unix-for-dummies-questions-and-answers/141994-how-check-mailx-unix.html)

kailash19 08-10-2010 10:16 AM

How to check mailx on unix?

I need to check if mailx utility is available or not on certail unix hosts.
I am trying to do that by a script, but dont how to check the mailx command .

I did

mailx -e
but the return status is 1, if no mails ,but thst means its running.
So how can i diffrentiate that mailx was not run or run.

pludi 08-10-2010 10:36 AM

Whats wrong with

mailx_path=$( which mailx )
if [ ! -z "${mailx_path}" -a -e "${mailx_path}" -a -x "${mailx_path}" ]
    echo "mailx available at ${mailx_path}"
    echo "mailx not available"

kailash19 08-10-2010 11:23 AM

Thanks for reply.
What is the -e option?

I tried it gives error "unknown test operator"

I am on HP-UX

---------- Post updated at 09:23 AM ---------- Previous update was at 09:03 AM ----------

Also , mailx is present and is executable, it is just that sometimes it doesnot run and return with error.

So , i need to check if mailx command is running or not.

methyl 08-10-2010 11:53 AM


So , i need to check if mailx command is running or not.
This is gibberish.
Pludi's response is quite correct to the question posed.

Please re-phrase in good English stating what you actually want to know.

Also, are all your hosts HP-UX ?

There is a whole lot of difference between mail (whether the command is "mail" "mailx" or whatever) working within a local server and mail working to external servers.

kailash19 08-10-2010 11:58 AM

Yes, all my hosts are HP-UX.

I mean is my mailx running fine(able to send mails or read).

I will be checking all hosts every 10mins(through cron), so cant send mails to a mailID every time for all the hosts, to check mailx.

methyl 08-10-2010 12:35 PM

Can we assume that you have a number of servers where the mail normallly works, and you need to know whether the mail is still working?

Let's home in a bit more:

What version(s) of HP-UX?

Are you definitely using "sendmail" for your mail transport?

Checking the entire mail service every 10 mins is paranoia for an Operating System which can work reliably for years. What sort of faults have you experienced which might make you want to do this?

We do run a basic monitor from cron every 15 mins to check count the number of mail items in /usr/spool/mqueue . On this busy machine should the count exceed 50 we raise an alert.

kailash19 08-10-2010 12:46 PM

Yes, you are right.

The version is 11.23, we use sendmail.

We have seen this type of errors:
"can not write to queue directory /var/spool/clientmqueue/ (RunAsGid=0, required=114): Permission denied."

We have our daily logs being mailed from diff servers to a distro(or some specific mailID's), we are seeing that sometimes some servers not able to mail.
We found after investigating that its b'coz mailx didnt work.

Now we need a laert which can inform if on some machines mailx is not working so we an ask someone to fix it(Support team).
There are more than 300 servers.

All times are GMT -4. The time now is 02:51 AM.

UNIX and Linux Forums
Search Engine Optimisation provided by DragonByte SEO v2.0.32 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Unix & Linux Forums Content Copyright©1993-2017. All Rights Reserved.
Forum Operations by The UNIX and Linux Forums