0

I can't seem to execute this command from a crontab. It works fine from the command line.

index.js

#!/usr/bin/env node

//do stuff

crontab

*/5 * * * * flock -n /tmp/reddit.lock /usr/local/bin/node /home/user/projects/reddit/index.js -u me -p 'pass' -vvv

error

/bin/sh: -c: line 0: unexpected EOF while looking for matching `''
/bin/sh: -c: line 1: syntax error: unexpected end of file
chovy
  • 72,281
  • 52
  • 227
  • 295
  • 100% sure you're not using backticks instead of quotes somewhere? Otherwise: what happens if you add an `env -i` in front of it on the command line? – Wrikken Nov 24 '14 at 08:47
  • it was a special character in the password: `pass\%word` fixes it. – chovy Nov 24 '14 at 09:27
  • Ah, yes, `%` usually means a newline character in crontab... The fact it talke about line 1 instead of line 0 should have made alarm bells ringing here indeed. – Wrikken Nov 24 '14 at 11:14

1 Answers1

0

My password has a '%' in it. So I had to remove the single quotes and pass the argument as:

*/5 * * * * flock -n /tmp/reddit.lock /usr/local/bin/node /home/user/projects/reddit/index.js -u me -p pass\%foo -vvv

This took me awhile to find the problem, hopefully it helps someone else.

chovy
  • 72,281
  • 52
  • 227
  • 295