0

I just setup a cron to restart 'Thin' application server for my Ruby application every hour. I have tried every method but the cron is giving error saying command not found. My script looks something like this

#!/bin/sh
cd /var/www/myapp
thin restart -C /etc/thin/myapp

(thinrunner is the name of the above bash script) crontab looks like this

0 * * * * /usr/local/bin/thinrunner

The error i get in email sent by crontab looks like this:

/usr/local/bin/thinrunner: 3: /usr/local/bin/thinrunner: thin: not found

I have also tried running it directly without creating a bash file but it says thin not found even then. I used the following to run directly

0 * * * * cd /var/www/myapp && thin restart -C /etc/thin/myapp

I have already done chmod +x thinrunner and when i run the script directly, it works as expected. So what could i be doing wrong?

thanks

B A
  • 101
  • Check your PATH – muru Jul 06 '17 at 10:05
  • @muru thanks. i just gave absolute path for the command as well and it worked :) – B A Jul 06 '17 at 14:55
  • If anyone stumbles upon this thread, I solved this by simply giving an absolute path to the thin command so that the third line in the bash script was /usr/local/bin/thin restart -C /etc/thin/myapp – B A Jul 06 '17 at 14:56

0 Answers0