« links for 2007-04-12 | Main | 世界徒手画圆冠军 (视频) »


crontab 转义 % 号时的奇怪问题

%(百分号)在 crontab 中是一个特殊字符,相当于回车,如果命令中包含 %,那么 % 之后的内容将作为标准输入赋值给前面的命令。

如果命令行中需要 %,那就得在 % 前面加一个反斜线“\”来转义,就变成了“\%”, 当然了,如果要用反斜线的话,那就是“\\”这样子啦。

不过,我要在计划任务中添加一个任务,是要每天分析前一天的 apache 日志。日志的文件名,是用命令行参数来指定的。昨天的日志文件名就写成这样子

$(date --date 'yesterday' '/%Y-%m/access_log_%Y_%m_%d.log')

比如今天是2007年4月13日,那这条命令的结果就是:

/2007-04/access_log_2007_04_12.log

因为我这是在命令行中指定日志文件的,所以在添加到 crontab 中以后,需要在 % 之前添加反斜线。但是却出现了意外,因为 crontab 把上面的那个命令结果变成了

/\2007-\04/access_log_\2007_\04_\12.log

反斜线竟然还在!

服了他了,我只好把命令写到一个文件里,然后在 crontab 里面调用那个文件了。


Comments

Discourage litigation. Persuade your neighbors to compromise whenever you can. As a peacemaker the lawyer has superior opportunity of being a good man. There will still be business enough.

I agree completely with what you said. Good Read. Keep it going..

Very fascinating subject , thankyou for posting.

Great blog but did you know 9/11 and 7/7 were staged events by MI6/CIA operations

I agree using the era, but, I think, that it's a Diplomat not a LeBaron.

Truly when someone doesn't understand then its up to other visitors that they will help, so here it happens.

Get prices from established cleaning firms. Then you have a bench mark of what you can charge.

you get scripted a significant or awesome piece of writing. i'm keen on this man so much. I could no longer offer made it healthier. I develop at youtube my warm and friendly describe and bring back also. thank you and all best.Koifutter

I want to start a website to post merchandise from home. Would a blog be fine? Or are there free sources for creating websites?.

I'm a political science major who had intended to go to law school, but most people tell me negative things about it, like its impossible to get in, very difficult to do well, and impossible to pass the bar or get a job when you get out. This is all very discouraging.. . What do I do? A political science degree isn't worth much if you don't go into law school afterwards, right? What else can I do with it?. . How do I decide to go to law school?.

Very great information can be found on website . "The quality of an organization can never exceed the quality of the minds that make it up." by Harold R. McAlindon.

Wahhhh,!! I dnt believe its food thats generating her tummy groww!!|tiitaBoo|

Ray, your argument ignores those of us who DO find his posts, including the "comments closed" bit at the end, entertaining.

Director Groves -
While a second targeting mailing is good in theory it has caught a number of us cities off guard mainly because we needed the following information:
1. What was the cutoff date that determines the mailout universe?
2. What is the definition of "historically mid-range" census tracts that received the second mailing?
3. How can we assure residents that there form was not lost/destroyed/misplaced?
A second mailing gives the impression that you are receiving it because the Bureau never received it in the first place. Our suggestion for 2020. Set the cutoff date publicly, mailout to historically HTC tracts, and go out and help people fill out the form and skip the coffee mugs

At the risk of sounding like a suck-up, Language Log gets a lot of citations these days, and it's SEO ranking is quite amazing. I doubt that George Will himself has read any of Mark's posts on this topic, but it seems likely that one of his interns (or whoever does his grunt work) HAS run across it and maybe even brought it to his attention. This is an OLD topic.

I’m very intrigued by Unconventional.

things that can match the feeling of sun rays, air or water directly touching your body two following a failed coup attempt, says

Post a comment