用鱼检查流浪者的状况


疯子哥哥
2025-03-14 07:44:16 (7天前)
  1. 我正在尝试编写一个鱼脚本来检查当前的流浪者状态并根据它做一些事情。一个简单的例子是:

检查流浪汉是否在运行,如果是,流浪汉停止,如果没有…

2 条回复
  1. 0# Hey ou | 2019-08-31 10-32



    找到了带有test和$ status的解决方案



    1.   # Get status
    2. vagrant status machine-readable | grep state,running

    3. Check status

      if test $status -eq 0

    4. # Vagrant is running
    5. vagrant halt
    6. # Send notification
    7. notify-send "Vagrant is halted."
    8. else

    9. # Vagrant is not running
    10. vagrant up
    11. # Send notification
    12. notify-send "Vagrant is up."
    13. end

    14. </code>

登录 后才能参与评论