Debian /etc/init.d/脚本没有运行? [英] Debian /etc/init.d/ script not running?

查看:319
本文介绍了Debian /etc/init.d/脚本没有运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用运行Debian的BeagleBone Black(最近的版本,BeagleBone网站提供了一个链接,我相信),我最近安装了Java。每次启动板时,我必须再次设置Java的PATH,如下所示。

  root @ beaglebone:/ etc / init .d#java -version 
-bash:java:command not found
root @ beaglebone:/etc/init.d# export PATH = $ PATH:/bin/jdk1.7.0_60/bin
root @ beaglebone:/etc/init.d# export JAVA_HOME = / bin / jdk1.7.0_60
root @ beaglebone:/etc/init.d# java -version
java版本1.7.0_60
Java(TM)SE运行时环境(build 1.7.0_60-b19)
Java HotSpot(TM)客户端虚拟机(构建24.60-b09,混合模式)
root @ beaglebone:/ etc / init。 d#

我想在启动过程中编写一个脚本来设置java,然后运行一些java程序。所以我写了一个脚本helium_startup.sh并将其放在init.d中,脚本如下所示:

  export PATH = $ PATH:/bin/jdk1.7.0_60/bin 
export JAVA_HOME = / bin / jdk1.7.0_60

我还没有编写我想在这里运行的程序,但是我想我可以放一条线,在这两行之后运行,对吧?然后我使用update-rc.d创建链接:

  root @ beaglebone:/etc/init.d# update-rc .d helium_startup.sh默认
update-rc.d:使用依赖关系引导排序
insserv:warning:脚本'helium_startup.sh'缺少LSB标记并覆盖

我相信警告不会影响任何东西?我检查过/etc/rc5.d来验证其中一个链接是否已经进行:

  root @ beaglebone:〜#cd / etc / rc5.d 
root @ beaglebone:/etc/rc5.d# ls
README S01sudo S03loadcpufreq S04wicd
S01boot_scripts.sh S01xrdp S03rsync S05saned
S01bootlogs S02apache2 S03ssh S06rc.local
S01capemgr.sh S03acpid S03udhcpd S06rmnologin
S01hostapd S03cron S04avahi-daemon
S01motd S03dbus S04cpufrequtils
S01rsyslog S03helium_startup.sh S04lightdm

而且,这些链接似乎是针对每个运行级别的。然后我重新启动Beaglebone(我已经尝试通过重新启动,拔掉它并按下电源按钮),并尝试检查java的版本:

  root @ beaglebone:/etc/rc5.d# java -version 
-bash:java:命令未找到

它失败了。我是Debian的新手(和Linux一般),这是我第一次使用BeagleBone Black,我不知道是什么问题。我也尝试将2行设置为/etc/rc.local中的Java路径,并且这也不起作用。



任何帮助将不胜感激



-Brandon

解决方案

您无法设置环境变量(PATH)永久在init脚本中。适当的地方将是 /etc/profile.d


中的脚本

I'm using a BeagleBone Black that runs Debian (the latest version that the BeagleBone website provides a link for, I believe) and I recently installed Java on it. Every time I boot the board I must set the PATH for Java again as shown below.

root@beaglebone:/etc/init.d# java -version
-bash: java: command not found
root@beaglebone:/etc/init.d# export PATH=$PATH:/bin/jdk1.7.0_60/bin
root@beaglebone:/etc/init.d# export JAVA_HOME=/bin/jdk1.7.0_60
root@beaglebone:/etc/init.d# java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) Client VM (build 24.60-b09, mixed mode)
root@beaglebone:/etc/init.d# 

I wanted to write a script to set up java during start-up and then run some java program. So I wrote a script "helium_startup.sh" and put it in init.d, the script looks like this:

export PATH=$PATH:/bin/jdk1.7.0_60/bin
export JAVA_HOME=/bin/jdk1.7.0_60

I haven't wrote the program that I would like to run here yet, but I think I could place a line to run it right after these two lines, right? Then I use update-rc.d to create the links:

root@beaglebone:/etc/init.d# update-rc.d helium_startup.sh defaults
update-rc.d: using dependency based boot sequencing
insserv: warning: script 'helium_startup.sh' missing LSB tags and overrides

I believe that the warning doesn't affect anything? I checked /etc/rc5.d to verify that one of the links was made:

root@beaglebone:~# cd /etc/rc5.d
root@beaglebone:/etc/rc5.d# ls
README              S01sudo               S03loadcpufreq   S04wicd
S01boot_scripts.sh  S01xrdp               S03rsync         S05saned
S01bootlogs         S02apache2            S03ssh           S06rc.local
S01capemgr.sh       S03acpid              S03udhcpd        S06rmnologin
S01hostapd          S03cron               S04avahi-daemon
S01motd             S03dbus               S04cpufrequtils
S01rsyslog          S03helium_startup.sh  S04lightdm

And, the links do appear to be made for each of the run levels. Then I reboot the Beaglebone (I've tried doing it by "reboot", unplugging it, and pressing power button) and attempt to check the version of java:

root@beaglebone:/etc/rc5.d# java -version
-bash: java: command not found

And it fails. I'm new to Debian (and Linux in general) and this is my first time using the BeagleBone Black, I'm not sure what the issue is. I also tried putting the 2 lines to set the PATH for java in /etc/rc.local, and that didn't work either.

Any help would be greatly appreciated.

-Brandon

解决方案

You can't set an environment variable (PATH) permanently in an init script. The appropriate place would be a script in /etc/profile.d

这篇关于Debian /etc/init.d/脚本没有运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆