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