免费注册 查看新帖 |

Chinaunix

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

linux下crontab中的命令行中含有”%”的话前面一定得加转移符”\” . [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-11-21 17:14 |只看该作者 |倒序浏览
linux下crontab中的命令行中含有”%”的话前面一定得加转移符”\” .






其实这跟Linux关系不大,倒是跟shell很是相关其实还是跟crontab最相关:)
当时crontab的log出错信息是:
  1. /bin/sh: -c: line 0: unexpected EOF while looking for matching “’

  2. /bin/sh: -c: line 1: syntax error: unexpected end of file
复制代码
下面这是从命令man 5 crontab中摘出的一段话:
  1.         The entire command portion of the line, up to  a  newline  or  %

  2. character,  will  be  executed by /bin/sh or by the shell specified in

  3. the SHELL variable of the cronfile.  Percent-signs (%)in the command,

  4. unless  escaped with backslash (\), will be changed into newline char-

  5. acters, and all data after the first % will be sent to the command  as

  6. standard input.
复制代码
意思就是说crontab将忽略"%"后面的字串,把其当作前面命令的输入部分

而且还有个crontab的例子用来说明这个:
  1. 0 22 * * 1-5   mail -s "It’s 10pm" joe%Joe,%%Where are your kids?%
复制代码

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
2 [报告]
发表于 2011-11-21 20:10 |只看该作者
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP