Personal computing discussed

Moderators: renee, SecretSquirrel, notfred

 
Kreshna Aryaguna Nurzaman
Gerbil XP
Topic Author
Posts: 406
Joined: Mon Apr 11, 2005 2:05 am

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

Sat Nov 28, 2009 5: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:
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:
[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:
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.
 
notfred
Maximum Gerbil
Posts: 4610
Joined: Tue Aug 10, 2004 10:10 am
Location: Ottawa, Canada

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

Sat Nov 28, 2009 2: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
 
Kreshna Aryaguna Nurzaman
Gerbil XP
Topic Author
Posts: 406
Joined: Mon Apr 11, 2005 2:05 am

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

Sun Nov 29, 2009 10:52 pm

Thanks, I'll try it.

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On