Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

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
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

 
discard

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.