Ubuntu service

先举个例子:

我们在Ubuntu中启动/停止mysql有两种方式:


>service mysql start



>/etc/init.d/mysql start

我一直用第二种方法,今天发现ubuntu升级以后开始报错(但是还能继续用):

root@lillian-VirtualBox:/etc/mysql# /etc/init.d/mysql restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop mysql ; start mysql. The restart(8) utility is also available.
mysql stop/waiting
mysql start/running, process 2556

也就是说Ubuntu推荐使用Upstart(对应的命令就是第一种). Upstart是ubuntu使用的,在其他的linux操作系统中,也可以同时使用前面提到的两种控制task的方法,但是实现的细节不同。

Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping themduring shutdown and supervising them while the system is running.

这里是Upstart的手册:

http://upstart.ubuntu.com/cookbook/#pre-start

使用这种方式启停mysql时,会运行/etc/init/mysql.conf这个配置文件。说白了就是一种脚本,用于在启停mysql前后做一些额外的工作,如pre-start等等。

具体用法在上面的手册中很详细。mysql.conf文件中使用的语言一部分是shell。我觉得应该是bash shell, 因为ubuntu的默认shell就是bash shell。

关于service和init.d还可以参考下面这个帖子:

http://askubuntu.com/questions/2075/whats-the-difference-between-service-and-etc-init-d

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值