bash - 在使用 systemd 启动 httpd 服务之前运行 bash 脚本

标签 bash centos7 systemd

我想在使用 systemd 启动 httpd 服务之前运行自定义 bash 脚本。我正在使用 Centos 7。

有什么想法吗?

亲切的问候。

最佳答案

假设你的httpd服务名为httpd.service,创建一个目录/etc/systemd/system/httpd.service.d;并在其中创建一个名为 run-my-script-first.conf(或任何您喜欢的名称)的文件,其中包含以下内容:

[Service]
ExecStartPre=/path/to/your/script

关于bash - 在使用 systemd 启动 httpd 服务之前运行 bash 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42999638/

相关文章:

读取管道后 bash 返回代码

ubuntu - 如何将自定义启动镜像上传到 MAAS

ubuntu - Bosh lite 中的 "Failed to connect to bus: No such file or directory"

linux - 在 Amazon Linux AMI CentOS 7 上安装 MariaDB 时出现依赖项错误

node.js - 使用 systemd 连接到 MongoDB,在 Linux (Debian) 上托管 Meteor (MeteorJS)。错误 : URL must be in the format mongodb://user:pass@host:port/dbname

service - 在 Ansible 中,服务和 systemd 模块有什么区别?

macos - bash 错误 : Cannot find/Library/. ..../setclasspath.sh,但它在那里

python - 显示文件和大小慢命令

linux - 检查用户是否属于 sudo 组的脚本

mysql - 如何清除在 CentOS 7 上运行的 mysqld.log 文件