23

I have a service in Linux.

When I start it use service start or start in init.d. It can't load config which has stored in /etc/ld.so.conf.d/. So some process which load the library path in /etc/ld.so.conf.d/. can't be launched by this service.

But when I run this service script in shell, it works fine.

How to load the library path in the /etc/ld.so.conf.d/?

Thanks a lot.

knb
  • 9,138
  • 4
  • 58
  • 85
JinruiDu
  • 353
  • 1
  • 2
  • 9
  • 2
    [The problem is service strips all environment variables but TERM, PATH and LANG ](http://unix.stackexchange.com/a/44378) Useful link help why service don't work. – JinruiDu Aug 22 '13 at 03:27

1 Answers1

37

Did you run ldconfig (as root) lately? There's a shared library cache that's updated by that program, and if you updated a file in /etc/ld.so.conf.d without running ldconfig, the cache data could be out of date.

C. K. Young
  • 219,335
  • 46
  • 382
  • 435
  • You mean I have to run ldconfig before service start? I will have a try. – JinruiDu Aug 20 '13 at 02:59
  • 2
    No, you have to run `ldconfig` after editing `/etc/ld.so.conf` or one of the files in `/etc/ld.so.conf.d`. After that, assuming you don't change those files, you don't usually need to rerun `ldconfig`. – C. K. Young Aug 20 '13 at 03:04
  • 3
    It doesn't work. I run **ldconfig** before **service myserv restart**. It still not run correctly. I have to `LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/myprog/lib export LD_LIBRARY_PATH ` After this, it could execute – JinruiDu Aug 20 '13 at 05:38
  • 1
    Well, that's easy, then. Add `/usr/local/myprog/lib` to a new file in `/etc/ld.so.conf.d` (maybe `myprog.conf`, if your program is really called `myprog`), then run `ldconfig`, then try again. – C. K. Young Aug 20 '13 at 10:40
  • 1
    Also, double-check that your `/etc/ld.so.conf` includes this line: `include /etc/ld.so.conf.d/*.conf`. Without that, nothing in `/etc/ld.so.conf.d` would get loaded. – C. K. Young Aug 20 '13 at 10:42
  • 2
    Yes. I had set the `/etc/ld.so.conf` as you said. But it didn't work. I have to export the path, in start script. I think this may cause by service load ENV have some limit. I will try search some document about service and env. Thanks a lot. – JinruiDu Aug 21 '13 at 01:47