I've been searching on this for 2 days. I tried three ways:

1.Add some file in init.d

Ok I have to admit I dun know how to see error log , seems promising but doesn't work

2.Try start thin server upon boot

I follow post this to last step, can run service thin start. then got lost.when I restart my machine the web page is still not on

3.Modify /etc/rc.local

This way seems eazy,I've tried few times.Just not working. Might because I dun know how to do 'change dir' and run 'rails s &' in correct format. and also have problem writing my own bash file/link to it in this file.

Say my rails folder is in /home/username/trail/myrailsapp How can I start it upon machine boot.

Please help me!Really newbie seek help! thanks in advance


why not just add a cronjob to start rails after rebooting?

crontab -e


@reboot rails /home/username/trail/myrailsapp/file.ruby &
  • sry I just go search cronjob,it says "For commands that need to be executed repeatedly (e.g., hourly, daily, or weekly), you can use the crontab command" but my problem is,my rails app is tracking data,if some one else reboot the server,and he(forgot to)turn on rails manually,data will be lost since then,So I need auto start rather than do it in short way.maybe ur code here can be put in a new bash file and then executed by rc.local?can it be done? – asdjkag Jul 9 '14 at 9:29
  • if you start the line with @reboot it will run the command when the computer starts up – Vasili Syrakis Jul 9 '14 at 9:59
  • what is this file.ruby ?Do I need to write it? – asdjkag Jul 10 '14 at 6:22
  • for this file.ruby I just neeed to put 'rails s' this two word inside? – asdjkag Jul 10 '14 at 6:28
  • Put @reboot <your command here> , mine is just an example. – Vasili Syrakis Jul 10 '14 at 8:26

Either you add a script in /etc/init.d and run update-rc.d <script> defaults as the link you provided suggests. Make sure to edit the variables in the init-script correctly!

To test it you can run service <script> start

A simpler way would be to just add a line in the file /etc/rc.local, this file also run on startup and you can run it as you normally would from shell. Use su -c or something if you need/can run it as someone else than root.

  • I try to follow and test,use update-rc.d <script> defaults and service <script> start, ( I added <> sing),it says"bash:defaults:permession denied" – asdjkag Jul 18 '14 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.