0

i run this command on the terminal

$ my_json_generator.rb | grep \"mtype\":164 | my_json_consumer.rb

json_generator creates json objects. 1 per line.

{"foo":7, "mtype":164, "bar":[1,2,3]}

I only need lines that contain mtype of 164 and for performance reasons ( and others outside the scope of this question ) i would like to avoid parsing the other json lines into objects. I recognize I could do this in code but need to avoid it.

So, the above command works on the terminal, but not in cron. Any suggestions appreciated.

Thanks!

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
Poul
  • 101
  • 1

2 Answers2

0

I guess you have a $PATH problem.

Try putting the full PATH of the executables, or add at the beginning of your crontab :

SHELL=/bin/bash
PATH=/bin:/usr/bin:/usr/local/bin
MAIL=me@domain.tld

* * * * * my_json_generator.rb | grep \"mtype\":164 | my_json_consumer.rb
Gilles Quénot
  • 1,313
  • 10
  • 17
0

What do you mean it doesn't work? Try removing the backslash from the Crontab entry. It might be double escaped.

Chloe
  • 1,164
  • 4
  • 19
  • 35