场景

crontab中需要新增一个自愈操作,如果进程不存在则重启进程。类似下面:

*/5 * * * * if [ -z $(ps -ef | grep filebeat | grep -v grep) ];then nohup /app/filebeat-7.7.0/filebeat -e -c /app/filebeat-7.7.0/kafka_log.yml &> /dev/null &;fi

但会报错:

-bash: syntax error near unexpected token `;'

解决方案

如果fi前面有&则可以不使用;进行隔离

*/5 * * * * if [ -z $(ps -ef | grep filebeat | grep -v grep) ];then nohup /app/filebeat-7.7.0/filebeat -e -c /app/filebeat-7.7.0/kafka_log.yml &> /dev/null & fi

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2021-11-19
  • 2021-06-06
  • 2021-05-22
  • 2022-12-23
  • 2021-06-01
猜你喜欢
  • 2021-12-30
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案