繁体   English   中英

systemd服务无法启动bash脚本

[英]systemd service failed to start bash script

我正在将bash脚本作为systemd服务运行,但这给了我这个错误

Failed at step EXEC spawning /home/pipeline/entity-extraction/start_consumer.sh: Permission denied Feb 8 11:59:58 irum systemd[1]: ee-consumer.service: main process exited, code=exited, status=203/EXEC Feb 8 11:59:58 irum systemd[1]: Unit ee-consumer.service entered failed state. 我的bash脚本正在运行2个Python脚本,当我从终端运行时,它运行良好
sudo bash start_consumer.sh
start_consumer.sh

while true
do
    echo "starting FIRST Consumer.py : $(date +"%T")"
    python3 /home/irum/Desktop/Marketsyc/Consumer.py &
    pid=$!
    echo "pid:$pid"
    sleep 60

    echo "starting SECOND Consumer.py : $(date +"%T")"
    python3 /home/irum/Desktop/Marketsyc/Consumer.py &
    new_pid=$!
    echo "new_pid:$new_pid"
    # Here I want to kill FIRST Consumer.py
    echo "killing first consumer"
    kill "$pid"
    sleep 60

    # Here I want to kill SECOND Consumer.py
    echo "killing second consumer"
    kill "$new_pid"
done

我的系统服务ee-consumer.service的代码

[Unit]
Description=Entity extraction - consumer
After=default.target
[Service]
Type=simple
Restart=always
User=pipeline
ExecStart=/home/pipeline/entity-extraction/start_consumer.sh

我该如何解决这个问题?

您必须设置脚本的shebang行和permission ,以便systemd执行。

在bash脚本的开头添加#!/bin/bash 然后执行以下操作

chmod 755 /home/pipeline/entity-extraction/start_consumer.sh

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM