我试图弄清楚如何在引导时运行命令,就像将其键入控制台一样。我在我的Raspberry Pi上使用了Rasbian,但我认为这个问题对于Debian来说通常是相同的。我要运行的命令是:
sudo screen mono server.exe
我尝试了以下解决方案,但是由于我刚开始使用Linux,所以不确定这是否正确。
#! /bin/sh
# /etc/init.d/server
### BEGIN INIT INFO
# Provides: server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Simple script to start a program at boot
# Description: ..
### END INIT INFO
# If you want a command to always run, put it here
sudo screen mono server.exe
exit 0
简单运行cd ~
然后编辑.profile
在底部,放入您想要的任何内容。
这种方式最适合我在Raspberry Pi上使用:
cd /home/pi
cd .config
mkdir autostart
cd autostart
只要文件名末尾带有.desktop
,则将其设置为任意名称:
nano screen_mono.desktop
然后将其写在该文件中以根据您的需要更改命令:
[Desktop Entry]
Type=Application
Name=Screen_mono
Exec=sudo screen mono server.exe
StartupNotify=false
这是我发现可以在Raspberry Pi上运行的唯一方法(我每次启动VNC服务器时都会启动它。
简单的答案,您转到/etc/rc.local
并添加命令。
不要忘记,您的脚本必须以“退出0”结尾。