[ubuntu][deepin]系统增加自定义开机启动项
[ubuntu][deepin]系统增加自定义开机启动项
进行配置
- cd /etc/init.d/
- ls
- vim myScript
nginx实例
#! /bin/sh
# chkconfig:
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx' ### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start:
# Default-Stop:
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO # Author: licess
# website: https://lnmp.org NGINX_BIN='/usr/local/nginx/sbin/nginx'
CONFIG='/usr/local/nginx/conf/nginx.conf' case "$1" in
start)
echo -n "Starting nginx... " PID=$(ps -ef | grep "$NGINX_BIN" | grep -v grep | awk '{print $2}')
if [ "$PID" != "" ]; then
echo "nginx (pid $PID) already running."
exit
fi $NGINX_BIN -c $CONFIG if [ "$?" != ]; then
echo " failed"
exit
else
echo " done"
fi
;; stop)
echo -n "Stoping nginx... " PID=$(ps -ef | grep "$NGINX_BIN" | grep -v grep | awk '{print $2}')
if [ "$PID" = "" ]; then
echo "nginx is not running."
exit
fi $NGINX_BIN -s stop if [ "$?" != ] ; then
echo " failed. Use force-quit"
$ force-quit
else
echo " done"
fi
;; status)
PID=$(ps -ef | grep "$NGINX_BIN" | grep -v grep | awk '{print $2}')
if [ "$PID" != "" ]; then
echo "nginx (pid $PID) is running..."
else
echo "nginx is stopped."
exit
fi
;; force-quit|kill)
echo -n "Terminating nginx... " PID=$(ps -ef | grep "$NGINX_BIN" | grep -v grep | awk '{print $2}')
if [ "$PID" = "" ]; then
echo "nginx is is stopped."
exit
fi kill $PID if [ "$?" != ]; then
echo " failed"
exit
else
echo " done"
fi
;; restart)
$ stop
sleep
$ start
;; reload)
echo -n "Reload nginx... " PID=$(ps -ef | grep "$NGINX_BIN" | grep -v grep | awk '{print $2}')
if [ "$PID" != "" ]; then
$NGINX_BIN -s reload
echo " done"
else
echo "nginx is not running, can't reload."
exit
fi
;; configtest)
echo -n "Test nginx configure files... " $NGINX_BIN -t
;; *)
echo "Usage: $0 {start|stop|restart|reload|status|configtest|force-quit|kill}"
exit
;; esac
模板
下面开始进行我们自己的配置
#! /bin/sh
# chkconfig:
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx' ### BEGIN INIT INFO
# Provides: [程序名称,唯一]
# Required-Start: $all
# Required-Stop: $all
# Default-Start:
# Default-Stop:
# Short-Description: [启动项的简短说明]
# Description: [启动项的完整说明]
### END INIT INFO [需要执行的命令] exit
咱们自己的
#! /bin/sh
# chkconfig:
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx' ### BEGIN INIT INFO
# Provides: myScript
# Required-Start: $all
# Required-Stop: $all
# Default-Start:
# Default-Stop:
# Short-Description: myScript
# Description: myScript
### END INIT INFO echo "myScript,hello word~~~" >>/home/myScript.txt exit
~~~~~~~~~~~~~~
如果要运行脚本或者程序,可以定义变量,但是会涉及一个开机自启程序读取本地配置或者文件的问题。
不定义也行,哈哈哈
BIN='/home/landv/go/src/aa/aa' $BIN
BIN是一个变量自己随便搞
~~~~~~~~~~~~~~
接下来,我们给myScript加上可执行的属性
- chmod + x myScript
然后加入开机启动项目中
“大便系列”
- update-rc.d myScript defaults
删除开机启动项目
- update-rc.d -f myScript remove
注意
/etc/init 是系统启动
/etc/init.d是应用启动
/etc/rc*.d这个是启动级别,具体级别含义请查询Linux启动级别
update-rc.d 这条命令就是把/etc/init.d/的配置加入这些级别中。
当然还有别的启动方式,先会这一种吧。
[ubuntu][deepin]系统增加自定义开机启动项的更多相关文章
- 如何修改Ubuntu双系统的默认开机启动项
转自:http://jingyan.baidu.com/article/ed15cb1b05d0311be369818a.html 对 于安装Ubuntu系统和windows系统(windows xp ...
- windows添加开机启动项
http://www.cnblogs.com/jokey/archive/2010/06/17/1759370.html添加开机启动项(通过注册表) 例子:增加QQ开机启动项 第一步:找到注册表的启动 ...
- 源码编译安装nginx及设置开机启动项
1.上传nginx文档:解压到/data目录下,并安装依赖包tar xf nginx-1.20.1.tar.gz -C /data/cd /data/nginx-1.20.1/ && ...
- Linux 系统开机启动项清理
一般情况下,常规用途的 Linux 发行版在开机启动时拉起各种相关服务进程,包括许多你可能无需使用的服务,例如蓝牙bluetooth.Avahi. 调制解调管理器ModemManager.ppp-dn ...
- Win10系统的开机启动项如何去关闭?
我们在使用电脑时会安装许多的应用程序,而有些应用程序会默认在电脑开机时自行启动,不仅影响开机速度,还会在开机后占用电脑内存资源. 那么在Win10系统中,我们该如何查看有哪些开机启动项呢?我们又该怎么 ...
- Linux的那些事-系统启动(增加开机启动项)
1 /etc/init.d 2 /etc/inittab 3 /etc/rc.d/init.d 1. /etc/init.d 是一般开机的启动服务存放在这个目录下,至于实现机制,其实 ...
- linux自定义开机启动服务和chkconfig使用方法
linux自定义开机启动服务和chkconfig使用方法 1. 服务概述在linux操作系统下,经常需要创建一些服务,这些服务被做成shell脚本,这些服务需要在系统启动的时候自动启动,关闭的时候自动 ...
- (转)linux自定义开机启动服务和chkconfig使用方法
原文:https://www.cnblogs.com/jimeper/archive/2013/03/12/2955687.html linux自定义开机启动服务和chkconfig使用方法 1. 服 ...
- mac系统下mysql开机启动总是3307
修改了mysql的my.cnf可还是不行,启动后就是3307,必须关掉再启动. 觉得可能是mac系统在哪里写死了开机启动项. http://queforum.com/mysql/1012987-mys ...
随机推荐
- 棋盘问题 POJ - 1321(dfs)
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int n, ...
- 1.谈谈对Java平台的理解
1.谈谈你对Java平台的理解 Java 本身是一种面向对象的语言,最显著的特性有两个方面,一是所谓的“一次编译,到处运行”(Compile once,run anywhere),能够非常容易地获取跨 ...
- R语言实战(第2版)PDF完整版带书签目录
<R语言实战2>PDF+源代码 下载:https://pan.baidu.com/s/1gP_16Xq9eVmLJ1yOsWD9FA 提取码:l8dx 分享更多python数据分析相关电子 ...
- nginx反向代理中神奇的斜线
nginx反向代理中神奇的斜线 在进行nginx反向代理配置的时候,location和proxy_pass中的斜线会造成各种困扰,有时候多一个或少一个斜线,就会造成完全不同的结果,所以特地将locat ...
- 正确写网站title、keywords、description
一.title title,也就是标题,是在浏览器上面显示出来的,方便用户了解这个页面的内容;特别是搜索引擎判断你网页内容的主要根据.搜索引擎就很大部分是依靠网站title来判断你网站是关于什么内容的 ...
- windows切换mac遇到的问题
1. 前端代码需要安装npm包 所以需要对整个文件夹都赋予管理员权限 2. 在npm i的时候如果权限不足 查看是哪一行调用了哪个文件夹,赋予权限 3. Dsp-fe 本地环境 除了需要配置host ...
- C程序疑问解答 ——可怕的野指针
本篇为原创,禁止任何形式的他用! 一.疑问点 指针是C语言一个很强大的功能,同时也是很容易让人犯错的一个功能,用错了指针,轻者只是报个错,重者可能整个系统都崩溃了.下面是大家在编写C程 ...
- KETTLE数据上传
1. KETTLE简介 一种ETL工具,ETL,是英文Extract-Transform-Load的缩写,用来描述将数据从来源端经过抽取(extract).转换(transform).加载(l ...
- nu.xom:Serializer
Serializer: 机翻 /* 使用用于控制空格,规范化,缩进,换行和基本URI的各种选项以特定编码输出Document对象 */ Serializer(OutputStream out) :创建 ...
- Excel催化剂开源第51波-Excel催化剂遍历单元格操作性能保障
在Excel催化剂推出的这一年多时间里,经常性听到一种声音,大概意思是真正会写代码的人,都不会看上Excel催化剂写出来的功能,自己造一个更舒服贴心,仿佛会一点VBA就可以天下无敌一般,也好像Exce ...