我想为/etc/init.d 中的每个服务设置安全限制说
ulimit -c unlimited
但这应该在发出“service <process> start
”或“/etc/init.d/<process> start
”时执行。
是否有一个通用路径,如果我们在那里写,它将应用于“启动”服务时的所有服务。
最佳答案
如果你创建一个像这样的文件:
/etc/init.d/.commonStuff
并在其中放入您希望对所有脚本通用的命令:(没有“#!/usr/bin/bash”行)
# This code is meant to be included by another script.
ulimit -c unlimited
umask 027
THIS_VARIABLE="will exist once the include is completed"
export THIS_VALIABLE # And now it is exportable too
然后在每个脚本中你可以添加这些行(在一个方便的地方):
# Include the common settings
. /etc/init.d/.commonStuff
前导点是“包含一些其他文件”指示符。
确保新文件受到保护(即由 root 拥有),并从中删除可执行标志以明确它不是要单独执行的。 (访问不能超过644)。
关于linux - 如何在启动每个服务之前执行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26480538/