简体   繁体   中英

systemd service failed to start bash script

I am running a bash script as systemd service but it is giving me this error

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. My bash scrip is running 2 Python scripts and it runs fine when I run it from terminal as
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

code of my systemd service 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

how can I resolve this issue ?

You have to set the shebang line and permission to the script, for systemd to execute.

Add #!/bin/bash to the start of the bash script. And do the following,

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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