22

On previous installed version kubuntu 15.xx i added a line into /etc/rc.local - /home/diet/scripts/my-auto-mount-script which obviously referred to a script that if on home wifi network drives should be mounted.

This worked flawlessly on kubuntu 15.xx

After the upgrade it seems /etc/rc.local is being ignored on boot because running the command /etc/rc.local still seems to do the trick. The reason I think rc.local is being ignored is because the script it refers to should produce logs on script success but also on script fail, but there are no logs.

Can anyone give me some pointers on how to troubleshoot this matter?

PS : yes I know that putting stuff in /etc/fstab is also a way of mounting the drives, but when I'm not at home I hate it that I can see the drives on dolphin and have those little red crosses on them because the are not there. This way when I'm on the road (it is a laptop) people can't see what i have at home.

Zanna
  • 70,465
Diet Bos
  • 327
  • Related: https://askubuntu.com/questions/919054/how-do-i-run-a-single-command-at-startup-using-systemd – mook765 Oct 07 '18 at 12:13

2 Answers2

26

Ubuntu is now using systemd, and rc.local is now considered a service which is turned "off" by default. You can turn rc.local "on" by entering the following command and rebooting:

sudo systemctl enable rc-local.service
Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
sshades
  • 261
  • Thank you very much for taking the time to provide me with a solution! i also found a solution that adding the script to ./.config/autostart-scripts/ also runs the script on startup! – Diet Bos May 14 '16 at 19:21
  • The sysemctl command works for me. Also note that this is different from user scripts in ~/.config/autostart-scripts as /etc/rc.local should run at boot time, before any user logs in. Note that any errors in the rc.local script may cause it to halt; scan /var/syslog for rc.local it it you think it does not work for you. – djb Sep 13 '16 at 16:38
  • 2
    And systemd doesn't support an "official way" to run scripts at startup? Like rc.local was? – Cirelli94 Oct 10 '16 at 08:59
4

only change this

chmod 755 /etc/init.d/rc.local

nano /etc/rc.local 

change this in first line

#!/bin/sh -e

to

#!/bin/bash 

save and enjoy!

muru
  • 197,895
  • 55
  • 485
  • 740
askopz
  • 41
  • 1