execute script before login
You may start any script from
/etc/rc.local
Better you create an upstart .conf file. These are stored in
/etc/init/*.conf
As an example, here are the contents of the file /etc/init/hostname.conf
:
#
# This task is run on startup to set the system hostname from /etc/hostname,
# falling back to "localhost" if that file is not readable or is empty and
# no hostname has yet been set.
description "set system hostname"
start on startup
task
exec hostname -b -F /etc/hostname
Another solution is using the crontab feature @reboot
, find out more about crontab here
Related videos on Youtube
bolek
Updated on September 18, 2022Comments
-
bolek over 1 year
Whole day I'm facing a startup script problem.
What I'm looking for is a way to run a single script at boot/before login that will configure my machine and run proper services. (Single script for all users would be cool - easy maintenance)
simple script "/machineSetup.sh"
#LC_NUMERIC - Specifies the decimal delimiter export LC_NUMERIC="en_US.UTF-8" #------------------------------------------------------------------- #add custom aliases path export PATH=$PATH:/home/user/aliases #------------------------------------------------------------------- #run backburnerServer (tool to control remote computing) run process /usr/discreet/backburner/backburnerServer & #------------------------------------------------------------------- #run x11vnc run process /usr/bin/x11vnc &
I'm on Ubuntu14.04. I already did tests with /etc/rc.local no luck at all. I tried /etc/profile.d/machineSetup.sh but it works only after login.
Would be cool if you can give me any hints. Is it possible at all to store configuration inside single file Thanks in advance for suggestions!
-
Admin about 8 yearsWhat is your purpose for starting x11vnc? Are you actually trying to provide remote VNC access to the display manager / login prompt, or do you really just want x11vnc to relay an established user session (i.e. 'desktop sharing')? Either way, "boot time" is not the place to do that.
-
Admin about 8 yearsWell , are we talking about starting this script for GUI or command line ? If we're talking both, you might want to add a check of whether or not this script is already been running , in order to avoid running it multiple times, if you choose to go through
.profile
route. Second thing, it may run in /etc/rc.local, but it runs as root, without any connection to GUI. So I am doubting it would be altering anyting . I would suggest you use/etc/lightdm/lightdm.conf
to link this with GUI and also avoid spawning multiple instances -
Admin about 8 years@steeldriver That's what i'm trying to do. I need to start backburnerServer without need to provide login info.
-
Admin about 8 yearsThis one worked for me http://askubuntu.com/questions/243044/why-isnt-rc-local-executed
-
-
bolek about 8 yearsThanks! Sure, but it works only after login. So it doesn't work for me.
-
bolek about 8 yearsThanks! but please check commentu under cmks answer.