Operating System - HP-UX
1753808 Members
7568 Online
108805 Solutions
New Discussion юеВ

Re: Empty /var/adm/messages

 
SOLVED
Go to solution
Raynald Boucher
Super Advisor

Re: Empty /var/adm/messages

Well, looks like smatador and Dennis are both right.
The error comes from the "grep -v date...".
I've taken it out for now but would still like to understand why the command is failing.

The cron command seems to be truncated at the first "%" character encountered as shown in the following cron log:
# tail -1000 log | grep dmesg
> CMD: /usr/sbin/dmesg - | /usr/bin/grep -v -e "ATI Radeon" -e "^$(date '+
> CMD: /usr/sbin/dmesg - | /usr/bin/grep -v -e "ATI Radeon" -e "^$(date '+
> CMD: /usr/sbin/dmesg - | /usr/bin/grep -v -e "ATI Radeon" -e "^$(date '+
> CMD: /usr/sbin/dmesg - | /usr/bin/grep -v "ATI Radeon" >> /var/adm/messages
> CMD: /usr/sbin/dmesg - | /usr/bin/grep -v "ATI Radeon" >> /var/adm/messages
> CMD: /usr/sbin/dmesg - | /usr/bin/grep -v "ATI Radeon" >> /var/adm/messages
> CMD: /usr/sbin/dmesg - | /usr/bin/grep -v "ATI Radeon" >> /var/adm/messages


The funny think is: the command works perfectly well from the command line or a shell script using the "usr/bin/sh" shell.
cron however seems to parse it differently.

Another thing, I received an error via roots mail when the grep command was written as grep -v "`date '+%b %e'`" but root stopped receiving errors once coded as grep -v "$(date '+%b %e')".

Can anyone shed some light on the differences in interpretation using these two forms?
Raynald Boucher
Super Advisor

Re: Empty /var/adm/messages

Finaly found the solution:
had to escape the "%" characters in the "date" command.

That might be a nice item to add to cron's man page.

Thanks all.

RayB

Dennis Handly
Acclaimed Contributor

Re: Empty /var/adm/messages

>had to escape the "%" characters in the "date" command. That might be a nice item to add to cron's man page.

Oops, didn't notice that, even though I have a \% in mine.

It's right there in crontab(1):
A percent character (%) in this field (unless escaped by a backslash (\)) is translated to a newline character ...
Raynald Boucher
Super Advisor

Re: Empty /var/adm/messages

Thanks Dennis,
I had been looking at the "cron" manpage instead of "crontab".

RayB