Linux service can't load library path in the /etc/ld.so.conf.d
Asked Answered
P

1

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.

Pipe answered 20/8, 2013 at 2:54 Comment(1)
[The problem is service strips all environment variables but TERM, PATH and LANG ](unix.stackexchange.com/a/44378) Useful link help why service don't work.Pipe
M
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.

Mandorla answered 20/8, 2013 at 2:55 Comment(6)
You mean I have to run ldconfig before service start? I will have a try.Pipe
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.Mandorla
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 executePipe
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.Mandorla
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.Mandorla
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.Pipe

© 2022 - 2024 — McMap. All rights reserved.