User avatar
magdesign
Posts: 13
Joined: Fri Mar 14, 2014 8:37 pm

rc.local after upgrade to jessie does not work

Mon Jan 25, 2016 5:09 pm

I have a complex system running on my RPi 2.

There are several commands in rc.local which must be executed on boot but after the network is up.
(mounting usb, screenblanking, executing scripts...)
Everything worked very well in debian wheezy.

However, after upgrading to jessie nothing seem to work anymore, I googled several hours and found out that people say that rc.local is now executed at a very early stage and that might be the reason why all my commands wont be executed.

How can I fix this?
Do I have to make an entry somewhere to tell jessie to execute rc.local as it did in wheezy or is there something new which replaces the rc.local?

I freaks me out, hope someone can bring light into the dark....

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5872
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: rc.local after upgrade to jessie does not work

Mon Jan 25, 2016 5:12 pm

You could migrate everything to your own systemd service, but you shouldn't have to.

rc.local is still executed.

If you need the network to be up, use raspi-config to enable that option.

Log the output of your commands to see exactly what happens.

gkreidl
Posts: 6047
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: rc.local after upgrade to jessie does not work

Mon Jan 25, 2016 5:20 pm

I simply added a
sleep xxx
(test the number of xxx seconds you need)
before the other commands. Not the most elegant approach, but it works.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

User avatar
magdesign
Posts: 13
Joined: Fri Mar 14, 2014 8:37 pm

Re: rc.local after upgrade to jessie does not work

Mon Jan 25, 2016 5:27 pm

Tried it, changed the option to: Wait for Network at boot in raspi-config
However, nothing changed.

But I just saw that there is a FAILED message at boot which tells:

Code: Select all

Failed to start /etc/rc.local Compatibility.
so I checked:

Code: Select all

systemctl status rc-local.service
which tells me:

Code: Select all

● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/lib/systemd/system/rc-local.service; static)
   Active: failed (Result: exit-code) since Mon 2016-01-25 18:16:55 CET; 3min 49s ago
  Process: 378 ExecStart=/etc/rc.local start (code=exited, status=203/EXEC)

Jan 25 18:16:55 pocketvj-100 systemd[1]: rc-local.service: control process exited, code=exited status=203
Jan 25 18:16:55 pocketvj-100 systemd[1]: Failed to start /etc/rc.local Compatibility.
Jan 25 18:16:55 pocketvj-100 systemd[1]: Unit rc-local.service entered failed state.
so I uncommented all the tasks in /etc/rc.local
the error still persists...

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5872
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: rc.local after upgrade to jessie does not work

Mon Jan 25, 2016 5:31 pm

Looks like the problem is with the content of rc.local.

User avatar
magdesign
Posts: 13
Joined: Fri Mar 14, 2014 8:37 pm

Re: rc.local after upgrade to jessie does not work

Mon Jan 25, 2016 5:35 pm

does it look different in "jessie"?

since it worked on wheezy, it should work (also when everything is commented out it should work).

my rc.local looks like this:

Code: Select all

mount -t auto /dev/sda2 /media/usb
cat /etc/motd; sleep 3
echo 0 > /sys/class/graphics/fbcon/cursor_blink
TERM=linux setterm -blank 0 -powersave off -powerdown 0 -foreground black -clear -cursor off >/dev/tty0
TERM=linux setterm -blank 0 -powersave off -powerdown 0 -foreground black -clear -cursor off >/dev/tty1
#/opt/vc/bin/tvservice -p &
/usr/bin/omxplayer-sync -mu -o both /media/internal/video/* &
service isc-dhcp-server restart
exit 0
also made a new, empty rc.local just with exit 0 at the end, made it executable with chmod a+x, still the error at boot... I guess something very importand changed on jessie...

User avatar
DougieLawson
Posts: 35798
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: rc.local after upgrade to jessie does not work

Mon Jan 25, 2016 5:39 pm

What happens if you run it in a terminal window with sudo sh -x /etc/rc.local?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
magdesign
Posts: 13
Joined: Fri Mar 14, 2014 8:37 pm

Re: rc.local after upgrade to jessie does not work

Mon Jan 25, 2016 5:45 pm

if I do:

Code: Select all

sudo sh -x /etc/rc.local
it executes all the things it should and starts all the stuff.


what I just saw is while booting on the very first line, RPi writes:

Code: Select all

[FAILED] Failed to start Load Kernel Modules.
Might this be an issue? If yes, do I have to do something to the Kernel after upgrading?

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5872
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: rc.local after upgrade to jessie does not work

Mon Jan 25, 2016 5:46 pm

Standard rc.local should work fine. On a standard clean image:

Code: Select all

● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/lib/systemd/system/rc-local.service; static)
   Active: active (exited) since Mon 2016-01-25 15:47:25 GMT; 1h 52min ago
  Process: 511 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
Edit: there are a number of things in your rc.local which aren't the right way to do things, but I'll leave those for now to keep on track. In general, I would recommend doing as much as possible outside of rc.local.

User avatar
magdesign
Posts: 13
Joined: Fri Mar 14, 2014 8:37 pm

Re: rc.local after upgrade to jessie does not work

Mon Jan 25, 2016 6:08 pm

I finally made a fresh install of debian jessie.

But it seems that rc.local does not work anymore. I tried several options like 'sleep 20' and 'after network'.

so, with this change on debian 8, everthing somewhow changed.... but I cant find any solution anywhere... googling since hours...

User avatar
magdesign
Posts: 13
Joined: Fri Mar 14, 2014 8:37 pm

Re: rc.local after upgrade to jessie does not work

Thu Feb 04, 2016 2:17 pm

@by ShiftPlusOne: what would be the proper solution to run this commands, since rc.local does not really exist anymore !

I'm totally confused,do I have to write systemd scripts or is this now systemctl ??

I have a solution with a webinterface and there I could easy switch the rc.local files content to execute the commands I wanted at startup, but without rc.local I have no idea how to do it...

Thanks for help!

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5872
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: rc.local after upgrade to jessie does not work

Thu Feb 04, 2016 2:30 pm

magdesign wrote:@by ShiftPlusOne: what would be the proper solution to run this commands, since rc.local does not really exist anymore !

I'm totally confused,do I have to write systemd scripts or is this now systemctl ??

I have a solution with a webinterface and there I could easy switch the rc.local files content to execute the commands I wanted at startup, but without rc.local I have no idea how to do it...

Thanks for help!
I don't know why you say rc.local doesn't exist any more. It does and I use it. Perhaps there's something about what you're putting in it that used to work but now doesn't, but rc.local itself still exists and is executed.

You can try an @reboot cron job instead.

User avatar
DougieLawson
Posts: 35798
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: rc.local after upgrade to jessie does not work

Thu Feb 04, 2016 3:08 pm

magdesign wrote:@by ShiftPlusOne: what would be the proper solution to run this commands, since rc.local does not really exist anymore !
Eh?

It there in Jessie, although I prefer to use /etc/cron.d files (or personal crontabs) to get things started @reboot or at timed intervals.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
magdesign
Posts: 13
Joined: Fri Mar 14, 2014 8:37 pm

Re: rc.local after upgrade to jessie does not work

Thu Feb 04, 2016 10:17 pm

Thanks for your help guys!!

these commands don't work anymore in rc.local:
TERM=linux setterm -blank 0 -powersave off -powerdown 0 -foreground black -clear -cursor off >/dev/tty0
TERM=linux setterm -blank 0 -powersave off -powerdown 0 -foreground black -clear -cursor off >/dev/tty1
also thanks for the tip with cron, made a task which now mounts the usb drives....

finally rc.local is working as expected.....

petemnz
Posts: 3
Joined: Fri Apr 24, 2015 11:56 pm

Re: rc.local after upgrade to jessie does not work

Tue Mar 08, 2016 8:05 pm

I have the same issue, cannot get rc.local to run at boot and tried cron as well thats not working @reboot either.
If I run rc.local after startup manually, it works. Have 5 other Rpi working fine with rc.local working on earlier versions.
So there is an issue with Jessie and rc-local.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2312
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: rc.local after upgrade to jessie does not work

Tue Mar 08, 2016 8:12 pm

Have you read through this thread?: viewtopic.php?f=66&t=122207

ccosse
Posts: 5
Joined: Sat Aug 16, 2014 6:09 pm

Re: rc.local after upgrade to jessie does not work

Thu Jun 01, 2017 1:27 am

At the top of /etc/rc.local you need to change

#!/bin/sh -x
to
#!/bin/bash

And it will work!

Martin Frezman
Posts: 1020
Joined: Mon Oct 31, 2016 10:05 am

Re: rc.local after upgrade to jessie does not work

Thu Jun 01, 2017 1:32 am

ccosse wrote:At the top of /etc/rc.local you need to change

#!/bin/sh -x
to
#!/bin/bash

And it will work!
Which problem is this intended to fix?
If this post appears in the wrong forums category, my apologies.

ccosse
Posts: 5
Joined: Sat Aug 16, 2014 6:09 pm

Re: rc.local after upgrade to jessie does not work

Thu Jun 01, 2017 2:12 am

Martin Frezman wrote:Which problem is this intended to fix?
This will make rc.local execute without failure ... on jessie lite

Martin Frezman
Posts: 1020
Joined: Mon Oct 31, 2016 10:05 am

Re: rc.local after upgrade to jessie does not work

Thu Jun 01, 2017 6:59 am

ccosse wrote:
Martin Frezman wrote:Which problem is this intended to fix?
This will make rc.local execute without failure ... on jessie lite
rc.local runs just fine for me.

It will work just fine as long as there's nothing that needs bash in it.

So, what is in your file that needs bash?
If this post appears in the wrong forums category, my apologies.

skypi
Posts: 111
Joined: Sat Aug 09, 2014 11:48 pm

Re: rc.local after upgrade to jessie does not work

Thu Jun 08, 2017 5:27 pm

I am having problems with running either rc.local or @reboot scripts on jessie lite on a pi zero, seems to be something to do with the state of the machine at either @reboot or rc.local in that the machine does not seem to have all the shell user state in place.

I am complicating things perhaps by using tmux -d to start a process under tmux but what I am seeing is that when I run @reboot starting tmux and then ssh in and start a new tmux session I get a $ prompt.

If I do not start tmux at @reboot and ssh in and then start a tmux session I get the full usual bash prompt in tmux.

something weird...

update:

OK so, it is a problem with the state of @reboot I think but can be fixed with a jiggerypokery trick

a) use rc.local instead

b) sudo -i -u pi <command>

so now the startup script app connects to pulseaudio thru tmux and subsequent ssh logins get access to pulseaudio... but with tests so far, only with pulse running system wide with a systemd startup unit.

ffs at last!!!!!

that command might work in crontab as well to get a full normal-state shell

(also I changed rc.local to #!/bin/bash at top not sure if that was also a factor, I know I have wasted time running $sh script when should have been $bash script LOL)

obviously credit to all the people I stood on the shoulders of eh!, here, stackexchange bunch, etc. etc.

Hcgrant
Posts: 19
Joined: Sun Oct 14, 2012 4:51 pm

Re: rc.local after upgrade to jessie does not work

Fri Nov 03, 2017 10:56 pm

ccosse wrote:
Thu Jun 01, 2017 1:27 am
At the top of /etc/rc.local you need to change

#!/bin/sh -x
to
#!/bin/bash

And it will work!
:D :D :D I had the same problem, I use rc.local to run a python script ... making that change to rc.local fixed things for me
Many thanks

nik_just_nik
Posts: 1
Joined: Thu Apr 12, 2018 10:11 am

Re: rc.local after upgrade to jessie does not work

Thu Apr 12, 2018 10:20 am

i am also facing this problem.
i interfaced the DS3231 based RTC with the Raspberry pi .

first i removed these commands
echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
sudo hwclock -s
date
and the rc.local worked normally.
then i replace the commands

echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
sudo hwclock -s
date
then rc.local starts normally.

User avatar
DougieLawson
Posts: 35798
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: rc.local after upgrade to jessie does not work

Thu Apr 12, 2018 12:07 pm

nik_just_nik wrote:
Thu Apr 12, 2018 10:20 am
i am also facing this problem.
i interfaced the DS3231 based RTC with the Raspberry pi .
Why are you running JESSIE? She retired last September.

Upgrade to Raspbian Stretch 2018-03-13 and interfacing the DS3231 is a million times easier.

Simply add

Code: Select all

dtoverlay=i2c-rtc,ds3231
to /boot/config.txt and reboot. That will enable /dev/rtc and /dev/rtc0 with no arcane echo command needed.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “Advanced users”