-1

When I tried exection grep function in particular directory its working on that directory but when I am trying to execute using absolute paths grep is not working for example

 grep `date +%Y-%m-%d` /var/wwww/file/file.log >> /home/filename/file.log

The above command output getting as empty file.
Is it possible to schedule grep in crontab to match text and generate valid output ?

HopelessN00b
  • 54,273

1 Answers1

1

The % in your crontab file gets turned into a newline character unless escaped with a backslash. Try

grep `date +\%Y-\%m-\%d` /var/wwww/file/file.log >> /home/filename/file.log

see

man 5 crontab

for details.

Tobi Oetiker
  • 1,952
  • 14
  • 13