rc.local doesn't execute my line, but it runs from root

Where Penguins and Daemons chill together in the warmth of the Sun.

Moderators: SecretSquirrel, notfred

rc.local doesn't execute my line, but it runs from root

Postposted on Sat Nov 28, 2009 4:30 am

I have an application called fgs. In order to start it, I need to do the four following tasks:
(1) Log in as kresh (user who owns the fgs application)
(2) cd /home/kresh/fgs
(3) . setenv.sh (from inside /home/kresh/fgs)
(4) fgs start (from inside /home/kresh/fgs)

I want fgs to autostart, so I put the following line in rc.local:
Code: Select all
su kresh -c "( cd /home/kresh/fgs/; . setenv.sh ; fgs start)"


But when I restart the server, fgs does not start. However, when I execute the above line as root:
Code: Select all
[root@devserv ~]$ su kresh -c "( cd /home/kresh/fgs/; . setenv.sh ; fgs start)

fgs starts flawlessly.

I suspect it is a login problem, ie, rc.local fails at the su kresh part.

I have tried the following line as well:
Code: Select all
sudo su kresh -c "( cd /home/kresh/fgs/; . setenv.sh ; fgs start)"

Again, rc.local doesn't seem to execute that, but executing it after logged in as root succeeds.

What should I do? By the way, I'm using CentOS 4.2.
Kreshna Aryaguna Nurzaman
Gerbil XP
 
Posts: 344
Joined: Mon Apr 11, 2005 1:05 am

Re: rc.local doesn't execute my line, but it runs from root

Postposted on Sat Nov 28, 2009 1:52 pm

ls -l rc.local and check the permissions on it. It should be owned by root:root and 755 permissions.

Also make the first line:
#!/bin/sh -e


and at the end
exit 0
notfred
Grand Gerbil Poohbah
 
Posts: 3647
Joined: Tue Aug 10, 2004 9:10 am
Location: Ottawa, Canada

Re: rc.local doesn't execute my line, but it runs from root

Postposted on Sun Nov 29, 2009 9:52 pm

Thanks, I'll try it.
Kreshna Aryaguna Nurzaman
Gerbil XP
 
Posts: 344
Joined: Mon Apr 11, 2005 1:05 am


Return to Linux, Unix, and Assorted Madness

Who is online

Users browsing this forum: No registered users and 3 guests