I encountered a strange problem in cron. According to crontab(5) man page, % has a special meaning in crontab commands. If used as it is, % is substituted with a new line. To preserve % in command line it has to be escaped with backslash. What I observe is that for every escaped % a character from the end of the command line is appended to it. For example, my crontab entry is: 27 13 * * * echo "\%a\%b 12345" This is converted into: Sep 7 13:27:00 fizia /USR/SBIN/CRON[1851]: (pike) CMD (echo "%a%b 12345"5") Looks strange, doesn't it? Am I hitting some known bug in cron? How can I use % without growing command line? This is SuSE 8.2, cron-3.0.1-701 Thanks, -Kastus
On Sun, Sep 07, 2003 at 11:44:59PM +0200, Philipp Thomas wrote:
Kastus
[Sun, 7 Sep 2003 13:33:01 -0700]: How can I use % without growing command line?
AFAIK you might just as well forget it. It just won't work :(
Thanks for the confirmation. Now I have to put my date command with a format string into a wrapper script to use it from cron. -Kastus
On Sunday 07 September 2003 11:19 pm, Kastus wrote:
On Sun, Sep 07, 2003 at 11:44:59PM +0200, Philipp Thomas wrote:
Kastus
[Sun, 7 Sep 2003 13:33:01 -0700]: How can I use % without growing command line?
AFAIK you might just as well forget it. It just won't work :(
Or use it as a feature 8-) if you add some spaces at the end of your string will it matter if they are duplicated?
Thanks for the confirmation. Now I have to put my date command with a format string into a wrapper script to use it from cron.
-Kastus
Hey, I'm no Unix expert, but couldn't you put "%" in your code? I.E., use the quote morks to isolate the sign? --doug, wa2say At 23:44 09/07/2003 +0200, Philipp Thomas wrote:
Kastus
[Sun, 7 Sep 2003 13:33:01 -0700]: How can I use % without growing command line?
AFAIK you might just as well forget it. It just won't work :(
Philipp
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com/http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
On Sun, Sep 07, 2003 at 06:40:28PM -0400, Doug McGarrett wrote:
Hey, I'm no Unix expert, but couldn't you put "%" in your code? I.E., use the quote morks to isolate the sign?
Unfortunately, it makes no difference to cron parser. When % sign stands by itself it is interpreted as new line and everything following it is fed as standard input to the command. When % character is escaped (\%) it should be passed as is to the command but crontab parser adds an extra character to the end of the command for each %. My original problem was that I wanted to use date command with format string from cron. E.g. date +\%Y-\%m-\%d It looks the only way to do it is to put it into a wrapper script. -Kastus
participants (5)
-
david stevenson
-
Doug McGarrett
-
Kastus
-
Kastus
-
Philipp Thomas