using flock inside crontab with node script throws an error

438 views Asked by At

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
1

There are 1 answers

0
chovy On

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.