1.运行shell脚本出现 /bin/bash^M: bad interpreter: No such file or directory问题
原因可能为 脚本是在 windows 下创建的, 移动到linux 在linux 运行 可能会出现此问题.
结局方法:
在脚本中 :set ff? 查看是 dos 还是 unix 如果为 dos 则 :set ff=unix 改成unix 然后 :wq 保存就可以了
2. ubuntu 设置 开机自启动脚本
先写一个脚本: test.sh
#!/bin/bash
#命令
exit 0
然后 chmod +x test.sh
然后将 脚本 添加到 /etc/init.d 中
并在 init.d 文件夹下 设置 开机的优先级
cd /etc/init.d
sudo update-rc.d test.sh defaults 90
移除 开机 脚本:
sudo update-rc.d -f test.sh remove