问题依然存在,/root/task/init.sh 脚本: #!/bin/bash 2 3 4 echo -e "create folder:jdk" 5 6 abs_path=$(cd $(dirname $0);pwd) 7 8 mkdir $abs_path/jdk 9 10
时间: 2024-04-13 08:31:11 浏览: 37
如果 `/root/task/init.sh` 脚本仍然没有被执行,我注意到你的脚本缺少了结束的部分。
在你的脚本中,你可以添加 `exit 0` 行来表示脚本顺利执行完毕并退出。这样可以确保 `/etc/rc.d/rc.local` 文件能够正确地执行完所有命令。
请将以下内容添加到 `/root/task/init.sh` 脚本的最后一行:
```bash
exit 0
```
然后保存并重启系统,看看脚本是否被成功执行。
如果问题仍然存在,请提供 `/etc/rc.d/rc.local` 文件的内容以及重启时的系统日志(可以使用 `dmesg` 命令或查看 `/var/log/messages` 或 `/var/log/syslog` 文件)以供进一步排查。
相关问题
问题依然存在 /etc/rc.d/rc.local内容如下: #!/bin/sh 2 # 3 # This script will be executed *after* all the other init scripts. 4 # You can put your own initialization stuff in here if you don't 5 # want to do the full Sys V style init stuff. 6 7 touch /var/lock/subsys/local 8 9 echo "Script executed" 10 11 /root/task/init.sh 12 #/usr/sbin/apachectl start 13 14 exit 0
根据你提供的 `/etc/rc.d/rc.local` 文件内容,看起来你想在启动时执行 `/root/task/init.sh` 脚本。但是你遇到了 `bad interpreter` 的错误。
这个错误通常发生在脚本的解释器路径不正确的情况下。请确保 `/root/task/init.sh` 文件存在,并且有执行权限(使用 `ls -l /root/task/init.sh` 命令来检查权限,使用 `chmod +x /root/task/init.sh` 命令添加执行权限)。
另外,请确保 `/root/task/init.sh` 文件的第一行指定了正确的解释器路径。例如,如果你使用的是 bash 解释器,第一行应该是 `#!/bin/bash`。
如果问题仍然存在,请提供 `/root/task/init.sh` 脚本的内容和执行过程中的完整输出,以便我能更好地帮助你解决问题。
centos 6.5 执行./init.sh 报 -bash: ./init.sh: bin/bash: bad interpreter: 没有那个文件或目录
这个错误通常表示脚本的解释器路径不正确。你可以尝试以下几个解决方法:
1. 确保脚本文件中的第一行指定了正确的解释器路径。例如,如果你使用的是 bash 解释器,第一行应该是 `#!/bin/bash`。
2. 检查脚本文件是否存在,并且你有执行权限。你可以使用 `ls -l` 命令查看文件权限,并使用 `chmod +x init.sh` 命令添加执行权限。
3. 确保你的系统中安装了脚本所需的解释器。在你的情况下,看起来是缺少了 `bash` 解释器。你可以通过运行 `which bash` 命令来检查解释器路径是否正确,并使用 `yum install bash` 命令安装 `bash` 解释器。
如果以上方法都没有解决问题,请提供更多详细信息,例如 init.sh 文件的内容和执行过程中的完整输出,以便我能更好地帮助你解决问题。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)