4

I am trying to run a cron-task using Rails schedule.rb file. The task invokes a function written in ruby. The function runs perfectly fine. However when trying to run as a cron I get this error.

Starting Spring server with `/home/ubuntu/.rvm/gems/ruby-2.4.0/gems/spring-2.0.2/bin/spring server --background` timed out after 20 seconds

Spring(2.0.2) is installed and working perfectly. Any idea how to solve this?

nishant
  • 896
  • 1
  • 8
  • 27

1 Answers1

-1

If the command works outside of cron, but not in the crontab, the problem is almost certainly that the command isn't picking up some necessary environment variable setting. There are several ways to get around the problem, but the simplest and best is to wrap your command in a shell script.

For initial testing, you can simply source your login environment:

. ~/.bash_profile 

But eventually you'll want to just set the variables you need and not include anything extra. For more information, see Define your own job types.

Kathryn
  • 1,557
  • 8
  • 12