构建 SysV 或 Upstart 兼容的 Bash 脚本的注意事项

发布于 2024-11-24 12:24:49 字数 385 浏览 4 评论 0原文

我刚刚敲出了一个快速脚本,用于使用 rsync 使从属 Web 服务器与主服务器保持同步。 (https://github.com/simonjgreen/liveFolderSync/blob/master/liveFolderSync.sh)

我想让它在启动时运行,并可以通过通常的 /etc/init.d/... 或服务命令进行控制,然而这是我一直陷入的一个领域。我发现 init.d 脚本和 upstart 脚本都非常混乱,并且无法在任何地方找到从头开始的指南。

我想要对其进行的唯一控制是启动/停止/重新启动。显然稍后我会将配置移至 /etc 中的单独文件中,但这已经在卡片上,因此超出了这个问题的范围。

任何指示/建议和最佳实践都会有所帮助。我应该补充一点,我是在 Ubuntu 上执行此操作的。

I've just knocked out a quick script for keeping a slave web server in sync with a master using rsync. (https://github.com/simonjgreen/liveFolderSync/blob/master/liveFolderSync.sh)

I'd like to make this run on boot and be controllable via the usual /etc/init.d/... or service commands, however this is an area I've always fallen down in. I find both init.d scripts and upstart scripts horrendously confusing, and can't find a guide anywhere for starting from scratch.

The only control I'd like to have over it is start/stop/restart. Obviously later I will move the config into a separate file in /etc but that's already on the cards so outside the scope of this question.

Any pointers/advise and best practices would be helpful. I should add that I'm doing this on Ubuntu.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鯉魚旗 2024-12-01 12:24:49

要开始使用 Sys V 初始化脚本,我建议使用以下链接:

  1. Linux:如何编写 System V 初始化脚本来启动、停止和重新启动我自己的应用程序或服务
  2. 为 Red Hat Linux 编写 System V 初始化脚本
  3. Ubuntu Bootup Howto

对于特定于 Upstart 的说明,我建议从以下内容开始:

目前,还有129 个问题 AskUbuntu,其中有几个将为您指明正确的方向:

To get started with Sys V init scripts, I suggest the following links:

  1. Linux: How to write a System V init script to start, stop, and restart my own application or service
  2. Writing System V init scripts for Red Hat Linux
  3. Ubuntu Bootup Howto

For instructions specific to Upstart, I would recommend starting with:

At present, there are also 129 questions on AskUbuntu, several of which will point you in the right direction:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文