I have some commands to in my rc.local. I know that they are failing. How can I get log file with messages produced by executing rc.local? Where is it located?

I have checked the /var/log/boot.log. I know my messages are not there because I know already what is the reason of failure. But I still want to make sure from log file.

Note, I don't want to run script again, I could but I don't want. I would rather analyse wht happened during startup.

Thanks for any help.

Ubuntu 12.04 Desktop (if it matters)

5 Answers 5


Unless a command has output or logging already configured, rc.local commands will not log anywhere.

If you want to see logs for specific commands, try redirecting the stdout and stderr for rc.local to somewhere you can check. Try adding this to the top of your /etc/rc.local file:

exec 1>/tmp/rc.local.log 2>&1  # send stdout and stderr from rc.local to a log file
set -x                         # tell sh to display commands before execution

Though this will require to rerun the rc.local file.

  • 3
    exec &> /tmp/rc.local.log is enough instead of the two exec calls :-) Jul 3, 2018 at 13:25
  • 3
    @abu-bua: Please be careful when you review edit suggestions that introduce functional changes! &> redirection is a Bash-ism and fails silently in Dash and other “plain” implementations of /bin/sh interpreters like the one used for rc.local. Sep 7, 2018 at 7:48
  • does "to the top" mean before the first line !/bin/sh -e?
    – bomben
    Sep 3, 2019 at 19:33
  • On Ubuntu 20.10, rc.local seems to be configured to log in /var/log/syslog. For that OS, see other answers for less intrusive ways to access rc.local output.
    – akaihola
    Dec 9, 2020 at 7:17

Try to check for failures in the /var/log/syslog file instead.

  • 1
    There are many lines so you can grep for rc.local for example like this: cat /var/log/syslog | grep rc.local
    – luke
    Nov 29, 2020 at 22:23

With systemd rc.local is considered a service fo which systemd collects logs. You can review them with:

systemctl status rc.local.service

You can see errors (if they exist) through service log.

  • 1
    On Ubuntu 20.10, this is systemctl status rc-local.service.
    – akaihola
    Dec 9, 2020 at 7:16
  • 1
    Great answer! Works on Raspian, as well. Feb 4, 2021 at 0:53

Look in

  1. /var/log/messages
  2. /var/log/daemon

Or use dmesg command

less /var/log/boot.log
less /var/log/dmesg
grep error /var/log/dmesg
grep <your expected error string> /var/log/boot.log

Or use script or some other tool to capture a log in rc.local


To add to Sylvain's answer:

grep rc.local /var/log/syslog

Will show you all error output related to rc.local

  • This is the correct answer. Nov 30, 2022 at 20:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .