创建一个在每周工作时间内以 15 分钟间隔运行的脚本
从周一到周五,上午 9 点到下午 4 点,我想点击特定的 URI。如果命中成功,我想创建/覆盖一个文件(这部分已完成)。我不确定使用 cron 作业执行此操作会更好还是创建后台服务会更好。我打算在具有 1 GB RAM 的 VPS 上运行它。我知道这很少,但这是我现在能负担得起的。使用 cron 作业或后台服务会更好吗?
From Monday to Friday, 9 am to 4 pm I want to hit a specific URI. If the hit succeeds, I want to create/overwrite a file (this part is done). I am not sure if doing this using a cron job will be better or creating a background service will be better. I intend to run this on a VPS with 1 GB of RAM. I know it's very little but that's all I can afford now. Would it be better to use a cron job or a background service?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会投票支持 cron 作业 - 在 crontab 中添加一行很容易,甚至可以将自定义文件放入
/etc/cron.d
目录中,如下所示:[编辑]来自注释:
就性能和资源而言,两者的要求都不是很高(假设您的脚本写得很好);话虽这么说,cron 已经在运行,所以它比添加另一个守护进程增加的开销更少。
至于维护,分发一些东西也很容易,只需将文件放在
/etc/cron.d/
中即可运行,并且不必向init.d
注册> 或暴发户
。I would vote for the cron job—it's easy enough to add a line to the crontab, or even put a custom file in the
/etc/cron.d
directory as follows:[EDIT] from comments:
In terms of performance and resources, neither is terribly demanding (assuming your script is well written); that being said, cron is already running, so it adds less overhead than adding another daemon.
As for maintenance, it's also easy to distribute something that simply places a file in
/etc/cron.d/
to run, and doesn't have to register withinit.d
orupstart
.