user3888415
user3888415

Reputation: 61

UNIX Ruby scripts on startup

I have three different scripts that I'd like to run on startup - currently I'm running them via:

nohup ruby script1.rb & disown

I can't seem to find how to run each of these scripts on startup, i.e. if the server happens to reboot.

/usr/bin/ruby
/usr/bin/gem

Distribution: Debian

Upvotes: 3

Views: 1550

Answers (1)

Paulo Fidalgo
Paulo Fidalgo

Reputation: 22296

You need to add the shebang line to your script:

#!/usr/bin/env ruby

and them make you script executable

chmod +x great_script.rb

and then use it with full path, like this

/home/user/bin/great_script.rb

Also you could add your scripts folders to path:

export PATH=/home/user/bin:$PATH

Since you don't mention your distribuition, you need to check how can you add a script to the startup system manager, although following what I've posted you are able to run Ruby scripts like any regular bash script.

UPDATE

In debian, according to the documentation

  1. copy your file to /etc/init.d/
  2. as root run: update-rc.d great_script.rb defaults

Upvotes: 3

Related Questions