直接启动postfix( postfix start )和作为服务( service postfix start )有什么区别? 什么(如果有的话)是最佳做法的首选方式,有没有办法使service postfix status显示进程作为活动,不pipe它是如何开始的?
一些代码进一步阐明:
root@luke:/# postfix status; service --status-all | grep postfix postfix/postfix-script: the Postfix mail system is running: PID: 17332 [ - ] postfix root@luke:/# postfix stop; service postfix start postfix/postfix-script: stopping the Postfix mail system root@luke:/# postfix status; service --status-all | grep postfix postfix/postfix-script: the Postfix mail system is running: PID: 18237 [ + ] postfix
作为一个系统服务启动它自然是最好的方法,其他的一切只能用于testing/debugging目的。
这样,该服务被集成到系统的正常启动过程中,并且可以轻松地打开或closures,以便以后重新启动,并且可以使用init系统的报告function。
对于手动启动的服务来说,这个报告( service xxxx status )是不容易实现的,而且当然不是不可能的,但是需要自己做一些工作才能实现(然后在更新时发生冲突)。
说到更新,这是使用系统服务的另一个重要优势,因为更新机制可以根据需要重新启动服务,具体取决于更新的configuration和性质。