Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


share|improve this question

I guess you have a $PATH problem.

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


* * * * * my_json_generator.rb | grep \"mtype\":164 | my_json_consumer.rb
share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.