'which systemd TYPE of service to use at machine start i some code has to stay forever

at the system start, using a systemd service, I want to lauch a bash to run forever, executing an action every 5 seconds.

Its code is simple (do_every_5_segons.sh)

    while true
    do
        {read some JSON from internet} >> $myLogFile  2>&1
        sleep 5
    done

So, in my service definition I write (~/.config/systemd/user/r4_start.service )

    pi@R4:
    [Unit]
    Description=R4 start 
    
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    Restart=no
    WorkingDirectory=/home/pi/tools
    ExecStart=/home/pi/tools/r4_start.sh

And in the "r4_start.sh", I do some trace and then launch my bash :

    nohup /home/pi/python/do_every_5_segons.sh &

The "&" is required so more init can be done after this line.

The "nohup" is required so the shell survives parent end.

My question is :

  • what is the correct service "Type" for this situation ?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source