I have a monitoring script in unix and any error messages it gives is stored as a mail in the unix box. Like wise it has accumulated lot of emails when i type mail command.
I have few questions.
1.How do i sort and read the mails--begining oldest to newest
2. In one of the box i typed mail and read all the messages . The next time i use the same command it doesnt show anything. Does it mean that the messages are gone or only the unread messages will be shown and the read messages are stored somewhere?
3. If i want to write a clean-up script so that i want to delete all the older mails more than 30 days old, how is it possible.
Do read you manual page for mail man mail first as there may be some variation based on operating system.
I don't know how to get them in reverse, but you can normally step through a page at a time by issuing z <enter> and that may help.
The second thing is that mail is often swept into a file in your home directory called mbox or .mbox after you have used the mail command. The get at it, try mail -f mbox (or .mbox of course)
It might be pretty tricky to auto-clean your mailbox. Perhaps you could script something that saves all the day's mail to a file and either have a history of the required number of days, or use the date as part of the name and issue a find to dispose of the older ones, e.g.
Like i said at the begginning though, read you manual pages carefully first.
Reading between the lines. If the monitoring script is running from unix "cron" any unredirected output will appear in the mail for the user owning the cron. If you redirect ALL output from the cron job to a file (or in selected cases /dev/null) there will be no email generated.
Hope this helps.
I am having trouble getting mail to work on a red hat server. At first I was getting this message.
Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused
Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
I am unable to cause the 'mail' command to send mail from my linux ubuntu 15.10 computer. File 'mail.log' typically reports Connection timed out.
I issue the command:
mail -s "my subject" recipient@domain.com < filenamewhere filename is a file containing my message.
Specifically, the... (3 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
The function will be called m and it will allow you to send an email to someone using the mail command. The... (1 Reply)
Hi All,
I am trying to send a mail from linux server but could'nt able to send the mail.
I tried the below syntax's so far but no luck.
mail -s “Hello world” abc@xyz.com < /usr/g/txt.log
cat "txt.log" | mailx -s "Hello world" abc@xyz.com
mailx -s “Hello world” abc@xyz.com <... (2 Replies)
Hi Guys,
Am tried with the mail & mailx command to send mail to other localhost machine, Which are all connected in a LAN. I can not able to send, Either it wont display any error message at that time and later am receiving a failure mail.. But i can send and receive (from-to) in my machine..... (28 Replies)
i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail.
actually i am trying to automate the high... (2 Replies)
Hi all,
I have written a script which supposed send a mail.
For testing I am just sending mails to my ID.
script I have written to send mail is-
#!/usr/bin/ksh
MAIL_FILE="$HOME/MAIL_FILE"
MAILOUT_LIST="milindb@example.com"
mail -s "Subject" $MAILOUT_LIST < $MAIL_FILE
if
then
echo... (6 Replies)
Hi ,
I am new to unix , i am using the mail and mailx command to send the mail .How come i will know the my mail command using which server as mail box..
Please help me ..
Thanks in advance (1 Reply)
Hell Sir/Mam,
I m new user in unix scripting, Please help me as soon as possible how CC by using Mail command in unix /Linux.
Thanking you. (2 Replies)
Dear All,
Now I use solaris 10 and I try to forward mail from /var/mail/username to their external mail so what should I do?
thank u in advance (2 Replies)