ubuntu添加开机启动
2024-08-27 19:57:23
vim /etc/init.d/mytest
#!/bin/sh echo "$(pwd) and $USER and $(whoami)" >> /root/temp/1.txt; mkdir -p /root/temp/; cd /root/temp/; echo "$(pwd) and $USER and $(whoami)" >> 2.txt
sudo chmod a+x /etc/init.d/mytest
sudo update-rc.d mytest defaults
sudo reboot
sudo service mytest status
service --status-all
sudo update-rc.d -f mytest remove
在temp目录下面会生成2个txt文件,1.txt的内容为:
/etc/init.d and and root
而2.txt的内容为:
root/temp and and root
说明在Ubuntu下,这种方式设置开机服务的方式,它的默认工作目录是/etc/init.d。而我们可以用个常见的bash命令cd来更改工作目录。
完。
最新文章
- 用JS做一个简单的电商产品放大镜功能
- XCode与Git的完美融合,不再依赖其它Git客户端
- Qt中2D绘图问题总结(一)----------基本的绘制与填充
- 2-5. Working with Compile Time Constants
- 51nod 1264 线段相交(几何)
- OpenGL的glTranslatef平移变换函数详解
- 根据url获取网页内容
- myeclipse-8.6.0下载
- HDU 1907
- oracle Form Builer:ID_NULL Built-in
- eclise -The method onClick(View) of type new View.OnClickListener(){} must override a superclass method
- 中文/英文双语言版本TWRP for Nexus5 -hammerheadcaf
- css3多列及瀑布流效果
- centos7基础学习第一天
- Exponentiation(java 大实数)
- linux centos-7.2-64bit 安装配置启动nginx
- Emmet之html语法
- [.NET] 使用 Senparc.Weixin 接入微信公众号开发:简单实现自动回复
- Java 通过getbean取出的类为什么要强转为接口类
- mysql 2006错误 导入时