关于Linux启动文件rc.local的解惑

背景

首先,rc.local是Linux启动程序在login程序前执行的最后一个脚本,有的服务器中在rc.local中可能会有一句touch /var/lock/subsys/local,这是干什么的呢,在百度中没找到,最终在Linuxquestions.org论坛成功找到满意的解答。

touch

首先要了解touch这个命令是做什么用的,在此用于创建一个不存在的文件,详细了解请见Linux touch命令

解释

/var/lock/subsys/local这个文件的存在证明rc.local这个脚本已经执行过了,目的在于避免这个脚本重复执行,除非这个文件不存在时,它才失效,也就是当系统关闭(shut down)时会发生,翻译的不是很好,原文是

What this does is create a lock file that tells the system that ‘local’ is up and running already. It prevents the script from being run twice, as it will fail until the lockfile is removed, which will

你可能感兴趣的:(学习总结,linux,服务器,脚本)