linux – monit从启动程序命令中删除引号
发布时间:2020-12-14 01:55:14 所属栏目:Linux 来源:网络整理
导读:我正在调试monit启动/停止程序语句.在我的/etc/monit.conf文件中,我的启动程序语句如下所示: check process node with pidfile /home/ec2-user/blah/node.pid start program = "/bin/su -c 'export APP_ENV=development; /home/ec2-user/local/bin/node /ho
我正在调试monit启动/停止程序语句.在我的/etc/monit.conf文件中,我的启动程序语句如下所示:
check process node with pidfile /home/ec2-user/blah/node.pid start program = "/bin/su -c 'export APP_ENV=development; /home/ec2-user/local/bin/node /home/ec2-user/example.com/current/api.js start &> /tmp/monit.out ' " stop program = "/bin/su -c '/home/ec2-user/local/bin/node /home/ec2-user/example.com/current/api.js stop'"" 我在shell中测试过 $sudo su # env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/sh # /bin/su -c '/usr/bin/env APP_ENV=development; /home/ec2-user/local/bin/node /home/ec2-user/example.com/current/api.js start &> /tmp/monit.out ' 运行它会在/tmp/monit.out文件中返回正确的输出: Starting nodejs daemon... nodejs daemon started. PID: 16408 但是当我运行sudo monit -v monitor节点时,它会显示一个不同的命令,除了内部单引号被删除之外: The service list contains the following entries: Process Name = node Pid file = /home/ec2-user/blah/node.pid Monitoring mode = active Start program = '/bin/su -c export APP_ENV=development; /home/ec2-user/local/bin/node /home/ec2-user/example.com/current/api.js start &> /tmp/monit.out ' timeout 30 second(s) Stop program = '/bin/su -c /home/ec2-user/local/bin/node /home/ec2-user/example.com/current/api.js stop' timeout 30 second(s) Existence = if does not exist 1 times within 1 cycle(s) then restart else if succeeded 1 times within 1 cycle(s) then alert Pid = if changed 1 times within 1 cycle(s) then alert Ppid = if changed 1 times within 1 cycle(s) then alert System Name = system_ip-xx-xx-xx-xx.ec2.internal Monitoring mode = active 我在monit文档中找不到任何相关内容.文档here似乎是最终的参考,但没有通过源代码,我不知道下一步该怎么做. 我的命令工作完美,没有删除引号,所以我只需要解决这个问题.欢迎所有想法和可能的修复. 解决方法
这是一个相当晚的答案,但我觉得它很重要,因为它会引起一些误解(所以我误导了)
您不需要转义单引号字符.试试吧: check process fake_proc with pidfile /tmp/test_pid start = "/bin/bash -c 'echo $$> /tmp/test_pid'" stop = "echo stop > /tmp/test_pid" 它不会显示为已启动的进程,但会创建test_pid文件.添加;睡眠xx以捕获进程并检查其属性. 问题可能是由某个特定环境问题引起的. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
推荐文章
站长推荐
- 如何在Powershell中使用Invoke-WebRequest重新创
- untagged – 如何招募linux大师
- algorithm – sed optimization(基于较小数据集的
- linux – 根目录中的100%inode,如何释放inode?
- 荣耀4.0系统怎么不root激活xposed框架的方法
- linux – 来自crontab的ssh返回’tcgetattr:无效
- [leetcode]187. Repeated DNA Sequences重复DNA序
- 如果我使用组件扫描并使base-package成为我的roo
- linux – Puppet VS Ansible什么是最好的自动远程
- 磁盘分区(2):格式化与挂载文件系统
热点阅读