LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Centos 7.2 /etc/rc.local replaced? (https://www.linuxquestions.org/questions/linux-newbie-8/centos-7-2-etc-rc-local-replaced-4175571550/)

bmxakias 02-05-2016 03:23 PM

Centos 7.2 /etc/rc.local replaced?
 
Hi

I was use on Centos 6.x this:

Code:

nano /etc/rc.local
and i add:

Code:

rm -f /var/sphinx/*.spl
/usr/local/bin/searchd --config /sphinxconfig/sphinx.conf

Now on Centos 7.2 this file is not used or it doesn't do exactly what was do or is not recommended for such edits.....

Can you please help me with this as i do not know what to edit or how to fix it now ? :(

Thank you

jpollard 02-05-2016 10:32 PM

Is the file executable?

Normally it would also have a "#!/usr/bin/bash" as the first line.

I believe it is only used if it is executable.

Doug G 02-05-2016 11:09 PM

With systemd you need to enable the rc-local.service
Code:

systemctl enable rc-local.service

bmxakias 02-06-2016 07:43 AM

yes it has on the first line the:

Code:

#!/bin/bash
No it is not executable... Ok i did it now....

Do i have to use also this?

Code:

systemctl enable rc-local.service

jpollard 02-06-2016 11:36 AM

yes (though you can drop the ".service" part.

You can test it without rebooting by "systemctl start rc-local"

bmxakias 02-06-2016 07:34 PM

This is what i got :(

Code:

[root@server ~]# chmod +x /etc/rc.d/rc.local
[root@server ~]# systemctl enable rc-local
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
  .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).


Doug G 02-06-2016 07:43 PM

Try putting your rc.local file in /etc/rc.d/rc.local, make sure it's marked as executable.

I haven't used rc.local in a couple years, apparently you no longer need to enable the rc-local.service, it's now a static unit.

jpollard 02-06-2016 07:48 PM

I think you can ignore that (I get it too).

Service units that do have an install section also have a "WantedBy=..." entry. rc.local doesn't have any services that depend on it.


All times are GMT -5. The time now is 08:53 PM.