systemd服务无法启动bash脚本

问题描述 投票:1回答:1

我运行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

我systemd服务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

我怎样才能解决这个问题呢?

python linux bash systemd
1个回答
2
投票

你必须设置shebang线和permission的脚本,systemd执行。

#!/bin/bash添加到bash脚本的开始。然后执行以下操作,

chmod 755 /home/pipeline/entity-extraction/start_consumer.sh
© www.soinside.com 2019 - 2024. All rights reserved.