Chinaunix

标题: 关于mail命令的一个问题!!先谢了 [打印本页]

作者: tohy    时间: 2006-02-23 17:26
标题: 关于mail命令的一个问题!!先谢了
我想定时将程序产生的日志文件发送到我的邮箱里面,听说用mail这个命令可以实现,各位能不能给介绍一下!谢谢了

[ 本帖最后由 tohy 于 2006-2-23 17:36 编辑 ]
作者: tohy    时间: 2006-02-23 19:05
标题: 没有人知道吗??
???
作者: boyhyc    时间: 2006-02-23 19:05
自己写个脚本,通过mail命令发就可以咯
作者: tohy    时间: 2006-02-24 15:06
直接mail to someone@163.com吗?
作者: fire-phoenix    时间: 2006-02-24 18:45
写一个简单的脚本即可放在crontab里定时发送。比如晚上12:00
crontab -e

  1. 30 00 * * * sh mail_log.sh 1>msg.out 2>msg.err &
复制代码


mail_log.sh

  1. #!/bin/bash
  2. log_file="/var/log/log_file"     #你要发送的日志文件
  3. date=$(date +"%Y-%m-%d")
  4. mail -s "[$date] log file content" someone@163.com < $log_file
  5. exit 0
复制代码


试试!看行不行。
作者: tohy    时间: 2006-02-24 20:42
我试试看
作者: kelela    时间: 2006-02-24 22:38
先把sendmail服务器搞定再说,默认只能localhost互通邮件
作者: fengwenzi    时间: 2006-02-25 13:32
mail -s "邮件标题" "目的邮件地址" < "内容"
作者: smallfish    时间: 2006-03-07 19:40
一定要先装sendmail吗?我用楼上朋友的说法给root发信却提示下面的错误:

[test@redflag test]$ mail -s hello root < mail
[test@redflag test]$ send-mail: warning: My hostname redflag is not a fully qualified name - set myhostname or mydomain in /etc/postfix/main.cf
postdrop: warning: My hostname redflag is not a fully qualified name - set myhostname or mydomain in /etc/postfix/main.cf
postdrop: warning: unable to look up public/pickup: No such file or directory

作者: skid    时间: 2006-03-08 11:00
我觉得应该用crontab -e




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2