How can I get a specific script to run (preferably not as superuser) whenever the machine boots, but before login. It can be the last thing to run on boot. I mostly just want the script to work even if no user logs in.
One possibility is to use Upstart. This lets you specify when you want to run your script in terms of dependencies, e.g. “when the filesystems are mounted and the network interface eth0 is up and running”. Create a file /etc/init/bruce_script.conf (you need to create the file as root) containing something like this:
description "Bruce's boot script"
start on filesystem and net-device-up IFACE=eth0
task
exec su -c '/home/bruce/script' bruce
Consult the upstart documentation for more information, in particular the init(5) manual page for a list of what you can put in that configuration file.
I would recommend using
cron
. The special time value of@reboot
will spawn your job at each reboot as your user. For example, runcrontab -e
and use:For more details on the special time formats, see
man 5 crontab
One possibility is to use Upstart. This lets you specify when you want to run your script in terms of dependencies, e.g. “when the filesystems are mounted and the network interface
eth0
is up and running”. Create a file/etc/init/bruce_script.conf
(you need to create the file as root) containing something like this:Consult the upstart documentation for more information, in particular the
init(5)
manual page for a list of what you can put in that configuration file.