服务器是 Debian 6.0。在 /etc/aliases 我有;
root: me@mydomain.com
Run Code Online (Sandbox Code Playgroud)
这是为了让根电子邮件直接发送给我。今天,我放入 /etc/cron.monthly 的每月脚本已通过电子邮件将其输出通过电子邮件发送给我。这是一个相当简单的脚本,看起来像这样;
#!/bin/bash
cd /a/directory
rm -rf ./*
wget http://www.site.com/fresh-copy.zip
unzip fresh-copy.zip
rm fresh-copy.zip
Run Code Online (Sandbox Code Playgroud)
我收到的电子邮件如下;
**Subject**: Cron <root@myserver> test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
**From**: root@my.server.com
**Body**:
/etc/cron.monthly/speedtest:
--2013-03-01 06:52:01-- http://www.site.com/fresh-copy.zip
Resolving www.site.com... 11.22.33.44
Connecting to www.site.com|11.22.33.44|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 99763924 (95M) [application/zip]
Saving to: `fresh-copy.zip'
0K .......... .......... .......... .......... .......... 0% 11.7M 8s
50K .......... .......... .......... .......... .......... 0% 11.3M 8s
100K .......... .......... .......... .......... .......... 0% 11.4M 8s
*CUT OUT FOR BREVITY*
97350K .......... .......... .......... .......... .......... 99% 16.9M 0s
97400K .......... .......... ..... 100% 11.6M=9.7s
2013-03-01 06:52:11 (9.78 MB/s) - `fresh-copy.zip' saved [99763924/99763924]
Archive: fresh-copy.zip
inflating: file1.ext
inflating: file2.ext
inflating: file3.ext
inflating: file4.ext
inflating: file5.ext
Run Code Online (Sandbox Code Playgroud)
此电子邮件中的唯一输出来自wget
andunzip
命令。我可以编辑脚本并将> /dev/null
其放在这两行的末尾,但这真的是最好的方法吗?如果我向生成输出的脚本添加更多命令,我将始终必须添加> /dev/null
到每一行。有没有办法可以禁用此 cron 脚本输出的电子邮件通知?
归档时间: |
|
查看次数: |
1747 次 |
最近记录: |