Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Linux上运行statrup脚本时出现问题_Linux_Tomcat_Startup_Registerstartupscript - Fatal编程技术网

在Linux上运行statrup脚本时出现问题

在Linux上运行statrup脚本时出现问题,linux,tomcat,startup,registerstartupscript,Linux,Tomcat,Startup,Registerstartupscript,我使用的是亚马逊风格的Linux uname -a Linux mydomain.org 3.19.25-82.99.amzn1.x86_64 #1 SMP Wed Dec 3 21:29:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux 我想在系统重新启动时运行以下脚本 ls -al /home/davea/install/apache-tomcat-6.0.35/bin/startup.sh -rwxr-xr-x 1 davea mycompany 20

我使用的是亚马逊风格的Linux

uname -a
Linux mydomain.org 3.19.25-82.99.amzn1.x86_64 #1 SMP Wed Dec 3 21:29:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
我想在系统重新启动时运行以下脚本

ls -al /home/davea/install/apache-tomcat-6.0.35/bin/startup.sh
-rwxr-xr-x 1 davea mycompany 2023 Nov 28  2011 /home/davea/install/apache-tomcat-6.0.35/bin/startup.sh
所以我创建了这个文件

-rwxr-xr-x 1 root root 73 Dec 10 19:29 /etc/init.d/start_tomcat
用台词

#!/bin/sh

sh /home/davea/install/apache-tomcat-6.0.35/bin/startup.sh
但是,当我重新启动系统时,不会调用此脚本。我遗漏了哪些步骤?登录后,我可以在命令行上很好地运行脚本

编辑:另外,我在/etc/rc.d中创建了这个符号链接

ls -al /etc/rc.d/start_tomcat
lrwxrwxrwx 1 root root 24 Dec 10 19:29 /etc/rc.d/start_tomcat -> /etc/init.d/start_tomcat

仍然不走运。

您必须将
init.d
下的启动脚本添加到默认运行级别

sudo update-rc.d /etc/init.d/start_tomcat defaults

哪个应该在相应的
/etc/rc?.d
文件夹下创建指向脚本的符号链接。

这取决于正在使用的启动程序。假设您有这样做的特权,并且如果启动程序是chkconfig程序,则etc/init.d/start脚本必须遵循这一点,因为您需要这样的头字段,如:

   # chkconfig: <levels> <start> <stop>
   # description: <some description>
您通常会创建一个名为serviceName.service的文件,其中包含以下条目:

[Unit]
Description=MyApp

[Service]

ExecStart=/path/to/myService/executable.sh

[Install]
WantedBy=multi-user.target
然后运行:

sudo systemctl enable /etc/systemd/system/hello.service
sudo systemctl start hello.service
如果这是一个LSB(基于Linux标准的)操作系统/启动,您应该遵循以下教程:


更新rc.d在哪里运行?当我尝试您列出的命令时,我得到一个“sudo:update rc.d:command not found”错误。@DaveA这里是
/usr/sbin/update rc.d
。正如我所说,脚本所做的只是在/etc/rc?下创建符号链接。dEven thouhg我没有/usr/sbin/update rc.d文件,我创建了一个符号链接(请参见我的编辑)。不幸的是,同样的结果(脚本未运行,服务器未启动)很好,现在在正确的运行级别下创建一个。阅读“/etc/init.d/README”;我的默认开始级别为2、3、4和5。因此,您需要在
/etc/rc2.d
/etc/rc3.d
/etc/rc4.d
/etc/rc5.d
下建立链接。另外,你应该在0,1和6下停止链接。我完全按照你说的做了,但没有运气。我感觉有些事情超出了我告诉你的范围,你的答案是正确的,但在我接受之前,我会先解决这个问题。谢谢,-戴夫
sudo systemctl enable /etc/systemd/system/hello.service
sudo systemctl start hello.service