[英]Shell how to kill a process and return 0
使用Ansible我有這個簡單的任務:
- name: kill selected APIS processes on API SERVER
shell: kill $(pgrep -f {{item}})
這個過程會被很好地殺死,但任務會拋出一個錯誤:
failed: "msg": "non-zero return code",
如上所示,也許我應該強制我的shell腳本返回0值(成功)
kill $(pgrep -f {{item}})
怎么做 ?
總是返回0的典型成語是kill $(pgrep -f {{item}}) || true
kill $(pgrep -f {{item}}) || true
但是在ansible中,使用ignore_errors
似乎是明智的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.