The percent semicolon (%) in the command line in Crontab needs to be escaped

Source: Internet
Author: User

Like what
I use orders in CRONTAB-E.
Echo-e "' Date ' +%s ' \t$random" >/tmp/xxx
Words
Direct use of command line no problem
But when it was written in Cron,
'% ' needs to be escaped into ' \% '
The reason has not been found
The reason has finally found
Look at Crontab's help under Linux
Mans 5 Crontab
In this section:

Percent-signs (%) in the command,
Unless escaped with backslash (\), 'll is changed into newline charac-
Ters, and all of the data after the ' the ' the ' a ' is sent to the command as
Standard input.

Probably meant to say
In the sixth column of the Cron file, which is the command column
A percent semicolon (%) is given a special meaning
is considered a newline character, and the content behind it is used as the standard input for the command

So, the ability to use the percent sign (%) normally
You need to add an escape character (\) before it


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.