crontab条目包含%号问题
来源:互联网 发布:java 线程安全的list 编辑:程序博客网 时间:2024/05/30 23:02
crontab条目中包含%号,最常见的取时间,如:date +%d,
对%需要使用\进行转义,否则不能按预期执行,正确做法为:
* * * * * echo "`date +\%d`" > /tmp/r1r.txt
而不能为
* * * * * echo "`date +%d`" > /tmp/r1r.txt
%是crontab的特殊字符,所有%后的被当作了标准输入,这可以通过“ man 5 crontab”查看到说明:
The entire command portion of the line, up to a newline or a "%" character,
will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile.
A "%" character in the command, unless escaped with a backslash (\),
will be changed into newline char-acters,
and all data after the first % will be sent to the command as standard input.
示例:
$ cat /tmp/hello.txt
cat: /tmp/hello.txt: 没有那个文件或目录
$ echo -e "`crontab -l`\n* * * * * cat > /tmp/hello.txt % hello word"|crontab -
$ crontab -l|grep hello.txt
* * * * * cat > /tmp/hello.txt % hello word
$ cat /tmp/hello.txt
hello word
对%需要使用\进行转义,否则不能按预期执行,正确做法为:
* * * * * echo "`date +\%d`" > /tmp/r1r.txt
而不能为
* * * * * echo "`date +%d`" > /tmp/r1r.txt
%是crontab的特殊字符,所有%后的被当作了标准输入,这可以通过“ man 5 crontab”查看到说明:
The entire command portion of the line, up to a newline or a "%" character,
will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile.
A "%" character in the command, unless escaped with a backslash (\),
will be changed into newline char-acters,
and all data after the first % will be sent to the command as standard input.
示例:
$ cat /tmp/hello.txt
cat: /tmp/hello.txt: 没有那个文件或目录
$ echo -e "`crontab -l`\n* * * * * cat > /tmp/hello.txt % hello word"|crontab -
$ crontab -l|grep hello.txt
* * * * * cat > /tmp/hello.txt % hello word
$ cat /tmp/hello.txt
hello word
阅读全文
0 0
- crontab条目包含%号问题
- Excel中使用自带的Filter筛选功能不能包含所有的条目问题
- 解决当ListView的条目中包含GridView时的问题
- crontab问题
- crontab 问题
- 谨防php包含文件的相对路径问题导致的crontab无法正常运行
- linux crontab执行shell脚本中包含相对路径的问题
- 一键自动往crontab添加条目脚本
- listView条目不能点击问题
- listView 条目错乱的问题
- 解决listview条目错乱问题
- listview条目长按问题
- ListView添加条目后,条目显示的顺序问题
- crontab使用注意问题
- crontab中的环境变量问题
- crontab 环境变量问题
- crontab使用问题
- crontab中的环境变量问题
- POJ 3463 Sightseeing(最短路次短路计数)
- JDK对国际化的支持
- 休整之后
- 三千记之知识备忘
- 引用与对象之Iterator中添加数据忘记new对象的错误
- crontab条目包含%号问题
- Spring Cloud Sleuth与Zipkin整合时遇到的问题记录
- 由浅至深学习block
- attribute value must be constant
- Git学习(GitHug安装及其闯关攻略)
- http协议笔记
- Swift3中数组创建方法
- poj 1509 Glass Beads(最小表示法模板题)
- 网页编程--JSON对象封装的三种方式