"/Bin/Sh: 1: Syntax Error: Redirection Unexpected" in Crontab's Outputs
In Crontab I Have This Job Script: 0 5 * * * /Home/User/Job_H. Bash > /Home/User/Log_H. Log > 2&1 Where the Job_H. Bash Contains: #! /Usr/Bin/Env Bash Set -E...
In crontab I have this job script :
0 5 * * * /home/user/job_h.bash > /home/user/log_h.log > 2&1
where the job_h.bash contains :
#!/usr/bin/env bash
set -e
source /home/user/pyenv/test/bin/activate
python3 /home/user/pyenv/test/d_h.py
deactivate
However it outputs "/bin/sh: 1: Syntax error: redirection unexpected"
Would you please help me to understand ? I'm pretty sure that i'm using the right shebang and finally the python isn't executed 🤷♀️
Thank you,
1 Answer
I almost certain your redirection for stderr is wrong. (the last 3 characters) Try
home/user/job_h.bash > /home/user/log_h.log 2>&1
The problem is your command, as written is trying to redirect stdout twice.