1

I try to run some commands at boot. I learned that one should add them in the /etc/rc.local file (on ubuntu 12.04 LTS).

Here my 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/touch /tmp/test.rc.local

exit 0

But after reboot no file was created in /tmp/ which indicates to me that rc.local was never executed.

Note: rc.local as (in my opinion) the right permission:

> ls -l rc.local 
-rwxr-xr-x 1 root root 446 Sep  3 15:55 rc.local
Rolf
  • 21
  • 2
  • When you are in a terminal as root and run ls -al /tmp/test.rc.local you get nothing after rebooting with the file like that? – Sylwester Sep 03 '13 at 21:22
  • The contents of /tmp can be--and often are--cleared on reboot. (Often, they are not even really written to disk.) /tmp is a place to store temporary files that don't need to be kept around. You should put the file elsewhere if you need to keep it. – Eliah Kagan Sep 03 '13 at 20:42
  • 1
    Yes /tmp gets cleared at every boot and rc.local should have created the file again since it's the last thing run. /tmp should have had that file even so. – Sylwester Sep 03 '13 at 21:11
  • Maybe it's a duplicate, but the other question doesn't really have a good answer. – Dronz Aug 14 '18 at 20:27

1 Answers1

0

As for you original idea

/usr/bin/xautolock -locker 'gnome-screensaver-command -a' -time 10

This seems strange for me. Both xautolock and gnome-screensaver-command are X-applications and init runs them in a console. Eg. they will fail because you don't have DISPLAY. You should add it as a startup application instead either global or just in your user. Search Startupapplications in the dash to see and add for your user only.

I would have added full path to the gnome-screensaver-command and remember to disable the original screeensaver.

Sylwester
  • 715