Reputation: 32899
I have the following command in my cron file:
*/15 * * * * NODE_ENV=production ~/bin/node ~/myapp/app.js > /var/log/nodelog/nodelog_`date "+%Y-%m-%d_%H-%M"`.log
The command itself runs OK when copied and pasted into the bash shell, but the cron job keeps sending the following error message:
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file
Why does it run OK from the command line, but fail in the cron job? Is there a difference between the syntax expected on the command line and that expected in cron?
Upvotes: 4
Views: 484
Reputation: 392833
Crontabs are error prone for the following general reasons:
Hints
env -i ./myscript.sh
Upvotes: 1
Reputation: 143061
From crontab manpage:
Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.
Upvotes: 4
Reputation: 1429
Look at the cron file permissions. If it is owned by you, then you can use ~. Otherwise use full path..!
Upvotes: 0