0

Here is my /etc/rc.local:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

sh /home/ubuntu/Desktop/camset.sh
exit 0

When I cd into /etc and run /home/ubuntu/Desktop/camset.sh, the script runs fine. The script just sets camera filters with v4l2-ctl. Is it possible that the camera is not yet connected/setup when the script runs? I have also made sure to make the script executable with chmod.

UPDATE: Here is my new rc.local file:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/usr/bin/screen -dmS autostart bash -c '/home/ubuntu/Desktop/camset.sh'
deflog on
logfile /tmp/screenlog_$USER_.%H.%n.%Y%m%d-%0c:%s.%t.log
exit 0

The only things in the tmp/ directory are: config-err-sHJlFD unity_support_test.0

  • Is your home directory encrypted? – Gilles Feb 12 '17 at 22:13
  • I don't think so – user215687 Feb 12 '17 at 22:29
0

There can be many reasons, and we don't know what your script is doing. What I would do is add some logging to find out what's happening.

See for example: Where is log file from rc.local?

The other approach (that I prefer) is to use the screen command to launch the process in its own terminal session.

Prerequisite:

apt-get install screen

Then you can add something like this to your local.rc file

/usr/bin/screen -dmS autostart bash -c '/home/ubuntu/Desktop/camset.sh'

In order to keep a log of the screen console also create a file /root/.screenrc like this:

deflog on
logfile /tmp/screenlog_$USER_.%H.%n.%Y%m%d-%0c:%s.%t.log

After reboot you can check the log file (in this example it's stored in /tmp).

PS: you may have to add an ampersand (&) after your script if it doesn't return, it could prevent the computer from booting.

Note that rc.local will be executed as root.

  • I tried this but there was no log file created – user215687 Feb 12 '17 at 22:37
  • If you type: screen -ls does it say "No Sockets found..." or something else ? – Anonymous Feb 12 '17 at 22:38
  • No Sockets found in /var/run/screen/S-ubuntu. – user215687 Feb 12 '17 at 22:56
  • Perhaps /usr/bin/screen is not the correct path on your system, check with: which screen and adapt if necessary – Anonymous Feb 12 '17 at 23:12
  • which screen returns "/usr/bin/screen" – user215687 Feb 12 '17 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.