user2647463
user2647463

Reputation:

Using tee with logger : syntax error near unexpected token `('

Scenario 1 : Command line

    ./myscript.sh 2>&1 | tee >(logger -t 'MYSCRIPT')

Works fine and perfect : displays errors and output msg on command line as well as puts in the lo

Scenario 2 : Adding it to a crontab

    20 19 * * * imuser /home/imuser/myscript.sh 2>&1 | tee >(logger -t 'MYSCRIPT')

Error : syntax error near unexpected token `('

What is that I am missing here ?

Upvotes: 2

Views: 2830

Answers (1)

glglgl
glglgl

Reputation: 91119

cron calls /bin/sh, which has a limited syntax compared to bash.

Try

20 19 * * * imuser /home/imuser/myscript.sh 2>&1 | bash -c 'tee >(logger -t MYSCRIPT)'

Upvotes: 6

Related Questions