免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1971 | 回复: 4
打印 上一主题 下一主题

[系统管理] linux crontab脚本执行的输出问题 [复制链接]

论坛徽章:
5
金牛座
日期:2015-07-03 13:32:00卯兔
日期:2015-07-03 13:32:17程序设计版块每日发帖之星
日期:2015-11-29 06:20:0015-16赛季CBA联赛之同曦
日期:2015-12-15 09:36:06CU十四周年纪念徽章
日期:2016-07-06 17:18:48
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-12-02 11:05 |只看该作者 |倒序浏览
  1. test.sh:
  2. #!/bin/bash

  3. echo "test std print!"
复制代码
设置crontab执行
* * * * * sh test.sh

并没有指定输出重定向,那么"test std print"会输出到哪里?

论坛徽章:
0
2 [报告]
发表于 2015-12-02 20:23 |只看该作者
如果你能执行?

论坛徽章:
84
每日论坛发贴之星
日期:2015-12-29 06:20:00每日论坛发贴之星
日期:2016-01-16 06:20:00每周论坛发贴之星
日期:2016-01-17 22:22:00程序设计版块每日发帖之星
日期:2016-01-20 06:20:00每日论坛发贴之星
日期:2016-01-20 06:20:00程序设计版块每日发帖之星
日期:2016-01-21 06:20:00每日论坛发贴之星
日期:2016-01-21 06:20:00程序设计版块每日发帖之星
日期:2016-01-23 06:20:00程序设计版块每日发帖之星
日期:2016-01-31 06:20:00数据库技术版块每日发帖之星
日期:2016-01-16 06:20:00程序设计版块每日发帖之星
日期:2016-01-16 06:20:00程序设计版块每日发帖之星
日期:2016-01-14 06:20:00
3 [报告]
发表于 2015-12-03 10:32 |只看该作者
/dev/null

论坛徽章:
5
金牛座
日期:2015-07-03 13:32:00卯兔
日期:2015-07-03 13:32:17程序设计版块每日发帖之星
日期:2015-11-29 06:20:0015-16赛季CBA联赛之同曦
日期:2015-12-15 09:36:06CU十四周年纪念徽章
日期:2016-07-06 17:18:48
4 [报告]
发表于 2015-12-03 11:22 |只看该作者
回复 3# yjh777

有相关资料吗?我从测试情况看是这样的。

可以确定的是,如果配置了MAILTO=root,错误输出是会mail给root的

   

论坛徽章:
84
每日论坛发贴之星
日期:2015-12-29 06:20:00每日论坛发贴之星
日期:2016-01-16 06:20:00每周论坛发贴之星
日期:2016-01-17 22:22:00程序设计版块每日发帖之星
日期:2016-01-20 06:20:00每日论坛发贴之星
日期:2016-01-20 06:20:00程序设计版块每日发帖之星
日期:2016-01-21 06:20:00每日论坛发贴之星
日期:2016-01-21 06:20:00程序设计版块每日发帖之星
日期:2016-01-23 06:20:00程序设计版块每日发帖之星
日期:2016-01-31 06:20:00数据库技术版块每日发帖之星
日期:2016-01-16 06:20:00程序设计版块每日发帖之星
日期:2016-01-16 06:20:00程序设计版块每日发帖之星
日期:2016-01-14 06:20:00
5 [报告]
发表于 2015-12-03 17:10 |只看该作者
是的默认发邮件的,-s 发送到系统日志:

CRON(                                                        System Administration                                                        CRON(

NAME
       crond - daemon to execute scheduled commands

SYNOPSIS
       crond [-c | -h | -i | -n | -p | -P | -s | -m<mailcommand>]
       crond -x [ext,sch,proc,pars,load,misc,test,bit]

DESCRIPTION
       Cron is started from /etc/rc.d/init.d or /etc/init.d when classical sysvinit scripts are used. In case systemd is enabled, then unit file is
       installed into /lib/systemd/system/crond.service and daemon is started by systemctl start crond.service  command.  It  returns  immediately,
       thus, there is no need to need to start it with the '&' parameter.

       Cron  searches  /var/spool/cron for crontab files which are named after accounts in /etc/passwd; The found crontabs are loaded into the mem‐
       ory.  Cron also searches for /etc/anacrontab and any files in the /etc/cron.d directory, which have a  different  format  (see  crontab(5)).
       Cron examines all stored crontabs and checks each job to see if it needs to be run in the current minute.  When executing commands, any out‐
       put is mailed to the owner of the crontab (or to the user specified in the MAILTO environment variable in the crontab, if such exists).  Any
       job output can also be sent to syslog by using the -s option.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP