LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-20-2014, 02:15 AM   #16
mahi_nix
Member
 
Registered: Aug 2010
Distribution: CentOS, RHEL, Ubuntu,
Posts: 154

Original Poster
Rep: Reputation: 16

Hi,

Command is not working. can you help me to create init script for this same process or command.

Regards,
Mahipal
 
Old 06-20-2014, 02:52 AM   #17
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by mahi_nix View Post
Hi,

Command is not working. can you help me to create init script for this same process or command.

Regards,
Mahipal
Doh, it should work! What it the error you get?
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"
2.
Code:
sudo -u rails /var/www/www.abc.com/start.sh
 
Old 06-20-2014, 02:59 AM   #18
mahi_nix
Member
 
Registered: Aug 2010
Distribution: CentOS, RHEL, Ubuntu,
Posts: 154

Original Poster
Rep: Reputation: 16
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
 
Old 06-20-2014, 03:06 AM   #19
mahi_nix
Member
 
Registered: Aug 2010
Distribution: CentOS, RHEL, Ubuntu,
Posts: 154

Original Poster
Rep: Reputation: 16
Hi bathory,

below is the error after applying your suggested solution.
Quote:
root@localhost:~# sudo -u rails /var/www/www.abc.com/start.sh
Could not locate Gemfile
Regards,
 
Old 06-20-2014, 03:14 AM   #20
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,848

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
I assume the cd into /var/www/www.abc.com is missing.
 
Old 06-20-2014, 05:35 AM   #21
mahi_nix
Member
 
Registered: Aug 2010
Distribution: CentOS, RHEL, Ubuntu,
Posts: 154

Original Poster
Rep: Reputation: 16
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,
 
Old 06-20-2014, 06:33 AM   #22
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Create the script:
Code:
#!/bin/sh
cd /var/www/www.abc.com 
./start.sh
Run it as the user rails:
Code:
su - rails -c "/path/to/script"
Try it from CLI first to see if it works, or it fails and for what reason
 
Old 06-20-2014, 07:10 AM   #23
mahi_nix
Member
 
Registered: Aug 2010
Distribution: CentOS, RHEL, Ubuntu,
Posts: 154

Original Poster
Rep: Reputation: 16
Hi,

below is the error.
Quote:
rails@localhost:~$ ./test.sh
Could not find rake-10.3.1 in any of the sources
Run `bundle install` to install missing gems.
I executed the script with rails user.

below is the another result of the command.
Quote:
su - rails -c /home/rails/test.sh
Gemfile syntax error:
/var/www/www.abc.com/Gemfile:36: syntax error, unexpected ':', expecting $end
gem 'xcases', git: 'ssh://user1@git.gitserver.com/var/lib/git/xcases.git'
Please suggest

Regards,

Last edited by mahi_nix; 06-20-2014 at 07:14 AM.
 
Old 06-20-2014, 07:27 AM   #24
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
below is the error.

rails@localhost:~$ ./test.sh
Could not find rake-10.3.1 in any of the sources
Run `bundle install` to install missing gems.
I'm not familiar with rails, but from the error above, looks like something is missing.
So as suggested, i.e. run "bundle install" and see what you get
 
Old 06-20-2014, 07:54 AM   #25
mahi_nix
Member
 
Registered: Aug 2010
Distribution: CentOS, RHEL, Ubuntu,
Posts: 154

Original Poster
Rep: Reputation: 16
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,
 
Old 06-20-2014, 08:14 AM   #26
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by mahi_nix View Post
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,
This is what the script of post #22 does:
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
 
Old 06-20-2014, 08:51 AM   #27
mahi_nix
Member
 
Registered: Aug 2010
Distribution: CentOS, RHEL, Ubuntu,
Posts: 154

Original Poster
Rep: Reputation: 16
Hi,

But I tried that way same as post:22 which also not works. I tried the same way suggested in post 22.

Regards,
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I start up a shell script when the system starts? resetreset Programming 6 03-01-2010 11:32 AM
start script bash when system start,stop,reeboot, how ?? melmar Linux - General 4 12-10-2009 06:58 AM
How to start squid command when computer start fedora rajunetha LinuxQuestions.org Member Intro 6 10-01-2009 12:48 AM
Set a Perl script as an unix service (start with system) onlymed Linux - Newbie 2 04-01-2009 02:59 PM
Trying to work out how to run a script with a start command or something similar helptonewbie Programming 6 05-31-2007 04:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration