登录前执行脚本

bol*_*lek 6 startup scripts login autorun

一整天我都面临启动脚本问题。

我正在寻找的是一种在启动时/登录前运行单个脚本的方法,该脚本 将配置我的机器并运行适当的服务。(所有用户的单一脚本会很酷 - 易于维护)

简单脚本“/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 &
Run Code Online (Sandbox Code Playgroud)

我在 Ubuntu14.04 上。我已经用 /etc/rc.local 做了测试,根本没有运气。我试过 /etc/profile.d/machineSetup.sh 但它只能在登录后工作。

如果你能给我任何提示,那就太酷了。是否可以将配置存储在单个文件中 提前感谢您的建议!

cmk*_*mks 5

您可以从以下位置启动任何脚本

/etc/rc.local
Run Code Online (Sandbox Code Playgroud)

最好创建一个新贵的 .conf 文件。这些存储在

/etc/init/*.conf
Run Code Online (Sandbox Code Playgroud)

例如,这里是文件的内容/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
Run Code Online (Sandbox Code Playgroud)

另一种解决方案是使用 crontab 功能@reboot在此处了解有关crontab 的更多信息