linux下crontab中的命令行中含有”%”的话前面一定得加转移符”\”

 其实这跟Linux关系不大,倒是跟shell很是相关其实还是跟 crontab最相关:)

当时crontab的log出错信息是:

/bin/sh: -c: line 0: unexpected EOF while looking for matching “’

/bin/sh: -c: line 1: syntax error: unexpected end of file

下面这是从命令man 5 crontab中摘出的一段话:

        The entire command portion of the line, up to  a  newline  or  %

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

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

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

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

 standard input.

意思就是说crontab将忽略"%"后面的字串,把其当作前面命令的输入部分

而且还有个crontab的例子用来说明这个:

0 22 * * 1-5   mail -s "It’s 10pm" joe%Joe,%%Where are your kids?%

你可能感兴趣的:(linux,shell,command,File,character,newline)