How to start command script in system start up ubuntu
Hi Guys,
I have ubuntu 12.04 server which has ruby site hosted on apache. now i must have to run one command in my site's root directory to start my sites as that command start ruby process. Please find the command details as below. Quote:
can anyone suggest me how can i run this command at the system startup with the specific user and in DocumentROOT of the web portal. I tried so many things and google out but no luck. Please help me to sorted out the issue. Regards, Mahipal |
what have you tried exactly? you can add start scripts in the rcX.d dirs.
|
Hi Pan64,
I tried to add that script in rcX.d but it dont works. I wanted to run that command script on specific directory (i.e. /home/rails/www.abc.com/" with user RAILS. Regards, Mahi_nix |
which script?
|
Hi Pan64,
Please find the command script as below: Quote:
Regards, Mahi_nix |
where did you put that start.sh? how did you set the permissions?
|
I have kept that scirpt in "/var/www/www.abc.com" directory, and the permission on script is 775.
I am starting this script by following below steps: 1) su - rails 2) cd /var/www/www.abc.com 3) ./start.sh This way i am manually starting this script. now i wanted to start this automatically at the boot time. |
you wrote:
Quote:
|
I added that script in /etc/init.d/ and then created symlink in rcX.d (i.e S20rubustart) and then reboot server to test it.
Regards, |
probably S99 would be better.
you need to combine all the steps in #7 into one single script I think. that will look like: Code:
cd /var/www/www.abc.com |
Hi,
I tried solution suggested by you but it didnt worked. Please find the error as below. Code:
root@localhost:~# ./start.sh Please suggest. Regards, |
I can only execute the start.sh script in "/var/www/www.abc.com" directory with rails user. script does not work with any other user and on any other location on server.
Regards, |
Quote:
Code:
su - rails -c "/var/www/www.abc.com/start.sh" |
Hi bathory,
I tried your suggested solution but it is not working. Regards, |
Quote:
|
Hi,
Command is not working. can you help me to create init script for this same process or command. Regards, Mahipal |
Quote:
You can also use any of the following 2 approaches: 1. Just put the command "/var/www/www.abc.com/start.sh" in a script and then use su to run it: Code:
su - rails -c "/path/to/script" Code:
sudo -u rails /var/www/www.abc.com/start.sh |
Hi Bathory,
I cant see any error message as it is running during the system startup and i dont have the console access of the server. i am accessing my server remotely using SSH. Let me try the above solution. I get back to you soon. Regards, Mahipal |
Hi bathory,
below is the error after applying your suggested solution. Quote:
|
I assume the cd into /var/www/www.abc.com is missing.
|
Hi,
cd is not missing. I have in the script. can you tell me how can i make a script which do the following steps. 1) su to rail (su - rail). 2) then cd to /var/www/www.abc.com (cd /var/www/www.abc.com). 3) then execute the scirpt ./start.sh can you tell me how can i make a script. might be that will resolve my issue. Regards, |
Create the script:
Code:
#!/bin/sh Code:
su - rails -c "/path/to/script" |
Hi,
below is the error. Quote:
below is the another result of the command. Quote:
Regards, |
Quote:
So as suggested, i.e. run "bundle install" and see what you get |
Hi bathory,
I am running this script from rails user's home directory, If i run the script command in /var/www/www.abc.com directory it will work as all the bundle components are installed in /var/www/www.abc.com directory. so i must have to run ./start.sh script in the said directory. I cant installed bundle components in the rails user's home directory. Regards, |
Quote:
Changes directory to /var/www/www.abc.com Runs the ./start.sh Then you, as root use su or sudo to execute the script with the rails user rights |
Hi,
But I tried that way same as post:22 which also not works. I tried the same way suggested in post 22. Regards, |
All times are GMT -5. The time now is 11:35 PM. |