0

i've installed a python software that allows to run javascript on the server

i've put the binary file (jsrunner) in this address

/usr/local/bin/jsrunner

so in the ssh when i try it it works fine

/usr/local/bin/jsrunner /home/domain/public_html/test.js

and i get some output from test.js

so i've put the same exact command in the cronjob

* * * * * /usr/local/bin/jsrunner /home/domain/public_html/test.js

but after a while i didn't get the expected result so i've enabled email report on cronjob and i got a email with this title

Cron <domain@CentOS-67-64-minimal> /usr/local/bin/jsrunner /home/domain/public_html/test.js

containig this error

/bin/sh: /usr/local/bin/jsrunner: No such file or directory

why there is /bin/sh: at the beginning of commend ? why it fails to find the file when i run it from cronjob ?

pleas note my cronjob works fine for other files like php using curl or binary , it's only this particular software/bin file that cuzing this error

hretic
  • 111
  • 1
  • 6
  • 3
    Are you sure that /usr/local/bin/jsrunner is a binary file and not a script with '#!/usr/bin/env python' or '#!/usr/bin/env node' ? – ALex_hha Mar 18 '16 at 15:41
  • Do `ls -la /usr/local/bin/jsrunner` and make sure there is an "x" flag set for the appropriate user. – zymhan Mar 18 '16 at 15:55
  • @ALex_hha 2 thing 1 - its working from terminal , if there was something wrong with the file i shouldn't be able to run it 2 - i've this working on my other servers it's just this new server is cuzing the error and only on cronjob – hretic Mar 18 '16 at 15:56
  • @WildVelociraptor here is the result `-rwxr-xr-x 1 root root 52M Mar 18 18:38 /usr/local/bin/jsrunner` – hretic Mar 18 '16 at 15:58
  • Are you sure that the user who is running the cron job has access to that path and file? Can you execute `/usr/local/bin/./jsrunner` when logged in as that user? – zymhan Mar 18 '16 at 20:05

1 Answers1

0

i've this working on my other servers it's just this new server is cuzing the error and only on cronjob

I had mostly the same issue but with inkscape binary. It works perfectly via apache but doesn't work via nginx. The root of the issue was environment variable PATH.

For example from cron

# crontab -l
* * * * * echo $PATH > /tmp/path.log

# cat /tmp/path.log
/usr/bin:/bin

From the console

# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/opt/nodejs/bin
ALex_hha
  • 7,025
  • 1
  • 23
  • 39