4

I have scoured the web and tried numerous solutions. Nothing has worked for me so far, hence this question.

I have a rails application that I run with mongrel_rails start -e production -p 80. That command has to be run from the directory of the application, in this case "/var/myapp".

This is the setup:

/etc/mongrel.sh

#!/bin/bash
sleep 15;
cd /var/myapp/
mongrel_rails start -e production -p 80

I added this (sh /etc/mongrel.sh) before exit 0 in /etc/rc.local

The above does NOT work, but it does work when run manually sh /etc/mongrel.sh. I have also tried running this in a screen session using: screen -d -m *command*.

Any suggestions to get this working as desired? I need this application running after boot.

3 Answers 3

2

You can add your script in cron job.

To add the script in cron job follow the below steps

  1. Open terminal with root access.
  2. Run crontab -e this command will allow you to edit your cron.
  3. Add the line @reboot sh /etc/mongrel.sh

The above process will execute that script once your computer boots up.

10
  • 1
    I found a post suggesting the same. I have run crontab -e and added @reboot sh /etc/mongrel.sh to the file. Exited (automatically saved the file) and rebooted reboot, didn't help.
    – Ralph
    Feb 23, 2015 at 20:30
  • 1
    Can you check Syslog file and check is it have any information about mongrel.sh script? and also under which you are try to run the script?
    – vembutech
    Feb 23, 2015 at 21:20
  • 1
    This is the output of cat /var/log/syslog.
    – Ralph
    Feb 24, 2015 at 9:01
  • 1
    Feb 24 08:50:57 vaatia-22-02-15 /usr/sbin/cron[1874]: (CRON) INFO (Running @reboot jobs)
    – Ralph
    Feb 24, 2015 at 9:02
  • 1
    Feb 24 08:50:57 vaatia-22-02-15 /USR/SBIN/CRON[1901]: (root) CMD (sh /etc/mongrel.sh)
    – Ralph
    Feb 24, 2015 at 9:03
1

Call /etc/mongrel.sh from /etc/rc.local. This script called rc.local is executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel, so you might use it to start your service,

1
  • 1
    Thank you for your answer but I don't think you read the question. The script is already being called from /etc/rc.local.
    – Ralph
    Feb 25, 2015 at 16:49
0

In rc.conf you have have to tell the system where sh is. So use:

/bin/bash/sh /etc/mongrel.sh

That will allow the system to run the script.

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.