简体   繁体   English

如何在启动时运行Linux Terminal命令

[英]How to run a Linux Terminal command at startup

I like to start my Siriproxy server on my Raspberry Pi on startup. 我喜欢在启动时在我的Raspberry Pi上启动我的Siriproxy服务器。 I have to type 我要打字

  1. cd siriproxy

  2. rvmsudo siriproxy server

in the Terminal to start the Siriproxy. 在终端启动Siriproxy。 Is there a way to run the command on the startup? 有没有办法在启动时运行命令?

Thanks a lot, 非常感谢,

David 大卫

This is the script I edited: 这是我编辑的脚本:

#!/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.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

#I added this line
/home/pi/siriproxy server

exit 0
/etc/init.d/cron start

You can add commands that are run as root to the /etc/rc.local script, and they will then be run at boot-up. 您可以将以root身份运行的命令添加到/etc/rc.local脚本中,然后它们将在启动时运行。 ( http://ubuntuforums.org/showthread.php?t=1822137 ) http://ubuntuforums.org/showthread.php?t=1822137

From a terminal on your raspberry pi, run: 从树莓派上的终端运行:

sudo nano /etc/rc.local

Add the following before the exit 0 line: 在退出0行之前添加以下内容:

/path/to/siriproxy server

You can get the path of siriproxy by typing 你可以通过输入获得siriproxy的路径

which siriproxy

or depending on how your pi has siriproxy installed, it could be the full path of whatever you cd'd to, then adding "siriproxy" to the end. 或者取决于你的pi如何安装siriproxy,它可能是你想要的任何东西的完整路径,然后添加“siriproxy”到最后。

Save the file and reboot to see it work! 保存文件并重新启动以查看它是否正常工作! Hope this helped. 希望这有帮助。

Try 尝试

screen -S ttlp
cd /home/pi/siriproxy

then 然后

rvm siriproxy server

I haven't tried this yet, I will install it on one of my Pi's and help you. 我还没试过,我会把它安装在我的一个Pi上并帮助你。

Regards, IC0NIC 此致,IC0NIC

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM