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来更改工作目录。

完。

最新文章

  1. 用JS做一个简单的电商产品放大镜功能
  2. XCode与Git的完美融合,不再依赖其它Git客户端
  3. Qt中2D绘图问题总结(一)----------基本的绘制与填充
  4. 2-5. Working with Compile Time Constants
  5. 51nod 1264 线段相交(几何)
  6. OpenGL的glTranslatef平移变换函数详解
  7. 根据url获取网页内容
  8. myeclipse-8.6.0下载
  9. HDU 1907
  10. oracle Form Builer:ID_NULL Built-in
  11. eclise -The method onClick(View) of type new View.OnClickListener(){} must override a superclass method
  12. 中文/英文双语言版本TWRP for Nexus5 -hammerheadcaf
  13. css3多列及瀑布流效果
  14. centos7基础学习第一天
  15. Exponentiation(java 大实数)
  16. linux centos-7.2-64bit 安装配置启动nginx
  17. Emmet之html语法
  18. [.NET] 使用 Senparc.Weixin 接入微信公众号开发:简单实现自动回复
  19. Java 通过getbean取出的类为什么要强转为接口类
  20. mysql 2006错误 导入时

热门文章

  1. [问题记录]Ubuntu下chmsee安装失败的解决
  2. 解决部分浏览器不能显示itext生成的PDF文件文本域内容问题
  3. (转)VIM 一键自动添加文件头注释
  4. Yii2.0数据格式器
  5. IOS中Llabel整理
  6. svn merge当主干修改后合并分支
  7. 为 Azure 应用服务配置连续部署工作流
  8. Chrome浏览器扩展程序的本地备份
  9. Java加腾讯云实现短信验证码功能
  10. Vue之父子组件的通信