crontab条目包含%号问题
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
crontab条目包含%号问题的更多相关文章
- 【HTTP】http请求url参数包含+号,被解析为空格
项目技术:Angular 6 问题现象:接口传参的时候,使用 httpClient.post 方法提交数据,字段中包含+号被解析成空格,提交数据错误 解决过程: 1.http请求中包含+号,会被自动解 ...
- jmeter问题处理随笔1 - CSV取值数据异常处理(包含"号,","号的情况)
背景 jmeter测试中通过CSV进行用例数据的管理,在result断言中间需要使用json格式的数据,会包含 " ",",这个时候发现CSV取值会报错或者乱码 解决 用 ...
- js传递参数中包含+号时的处理方法
encodeURI(url).replace(/\+/g, '%2B') 例子: $scope.getAnesthesiawaystatistical = function (annual, anes ...
- 自学Linux Shell15.2-作业控制命令(jobs/bg/nice/renice/at/atp/atrm/crontab)
点击返回 自学Linux命令行与Shell脚本之路 15.1-作业控制命令(jobs/bg/nice/renice/at/atp/atrm/crontab) 1 控制作业 1.1查看作业 (jobs ...
- Linux crontab 定时任务命令详解
一.简介 crontab 命令用于设置周期性被执行的指令.该命令从标准输入设备读取指令,并将其存放于 crontab 文件中,以供之后读取和执行.通常,crontab 储存的指令被守护进程激活, cr ...
- Linux新手学堂 Crontab命令的语法
crontab 命令的用途就是:提交.编辑.列出或除去 cron 作业. 语法 crontab [ -e [UserName] | -l [UserName] | -r [UserName] | -v ...
- linux crontab定时执行shell脚本
linux下使用crontab命令被用来提交和管理用户的需要周期性执行的任务,示例如下:crontab -e 编辑周期任务30 21 * * * /etc/init.d/smb restart 每晚的 ...
- Linux Crontab 任务管理工具命令以及示例
Crontab 是 Linux 平台下的一款用于循环执行例行任务的工具,Linux 系统由 cron (crond) 这个系统服务来控制任务 , Linux系统本来就有很多的计划任务需要启动 , 所以 ...
- shell 中的 eval 及 crontab 命令
eval eval会对后面的命令进行两遍扫描,如果第一遍扫描后,命令是个普通命令,则执行此命令:如果命令中含有变量的间接引用,则保证间接引用的语义.也就是说,eval命令将会首先扫描命令行进行所有的置 ...
随机推荐
- Android沉浸式状态栏背景色以及字体颜色的修改
在activity中设置透明状态栏 的思路: 1.让activity的布局全屏 此时布局会和状态栏重叠 2.让布局最上方预留出和状态栏高度一样的高度,将状态栏的背景色设置为透明 效 ...
- Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause; this
最近使用新版本的mysql,执行语句的时候报错.网上找了一下,解决方法如下: vim /etc/mysql/conf.d/mysql.cnf [mysqld] sql_mode=STRICT_TRAN ...
- python re正则
一:什么是正则? 正则就是用一些具有特殊含义的符号组合到一起(称为正则表达式)来描述字符或者字符串的方法.或者说:正则就是用来描述一类事物的规则.(在Python中)它内嵌在Python中,并通过 r ...
- 使用clear来清除localStorage保存对象的全部数据
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- msysgit解决中文乱码问题
项目中在用git,安装msysgit客户端后处理中文是有问题的: ls中文目录/文件名乱码:提交中文的log,push到服务器上会乱码:git log查看服务器pull过来的log乱码. 1.ls命令 ...
- Vim完全教程
一.简介 世界上只有三种编辑器,EMACS.VIM和其它. 我们所处的时代是非常幸运的,有越来越多的编辑器,相对于古老的VIM和EMACS,它们被称为现代编辑器.我们来看看这两个古董有多大年纪了: ...
- 学习javascript怎么入门,初学者5条建议
你是否已经初步掌握了html和css,但完全不知道从何入手Java?如果是,这里总结了5条建议,帮助JavaScript初学者总结学习方法,提高学习效率. 一.多看视频少看书 对初学者而言,看书的效率 ...
- Error starting daemon: error initializing graphdriver: driver not supported
Error starting daemon: error initializing graphdriver: driver not supported systemctl stop docker rm ...
- python中的迭代器 生成器 装饰器
什么迭代器呢?它是一个带状态的对象,他能在你调用next()方法的时候返回容器中的下一个值,任何实现了__iter__和__next__()(python2中实现next())方法的对象都是迭代器,_ ...
- 【解决办法--实测可行】Partition 1 does not start on physical sector boundary.
新的硬盘使用fdisk进行划分的时候有提示Partition 1 does not start on physical sector boundary.后面按网上找的办法,在fdisk进行分区的时候, ...