0

I created a system service file the I want to execute a command whenever the program stops running or or computer restarts.

I want "pocket start" to run always. When I type it in the terminal, it kicks off a job that runs in the background that syncs to a blockchain.

Here's what I've done so far:

sudo nano /etc/systemd/system/pokt.service

Then entered the following:

[Unit]
Description=Pokt Client
After=network.target
Wants=network.target

[Service]
Type=simple
Restart=always
RestartSec=5
ExecStart="pocket start"

[Install]
WantedBy=multi-user.target

whenever I start the service using:

 sudo systemctl start pokt.service

and check the status, this is the error I get:

● pokt.service - Pokt Client
     Loaded: loaded (/etc/systemd/system/pokt.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Sat 2022-04-23 12:16:35 CDT; 1s ago
    Process: 10361 ExecStart=pocket start (code=exited, status=203/EXEC)
   Main PID: 10361 (code=exited, status=203/EXEC)
        CPU: 1ms

Not quite sure what I'm doing wrong. I'm running ubuntu 22.04

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • The binary you started exited with the status 203 - usually anything different from 0 is indicating an error. Try to look for logfiles from the program or look in the docs, what that status code means. In general you should be better off with that question either in [SU] or https://askubuntu.com/, two other stack exchange communities. – cyberbrain Apr 23 '22 at 17:53
  • From the tag: systemd questions should be for *programming questions* using systemd or its libraries. Questions about *configuring the daemon* (including writing unit files) are better directed to Unix & Linux: https://unix.stackexchange.com. – Rob Apr 24 '22 at 09:38

1 Answers1

0

Maybe you can give it a try by updating the "ExecStart" with the Absolute/Full path of pocket.

You can find the Full path by executing "whereis pocket" or "which pocket" !

  • i just tried that, but no beuno. `[Unit] Description=Pokt Client After=network.target Wants=network.target [Service] Type=simple Restart=always RestartSec=5 ExecStart='/home/pokt/go/bin/pocket start' [Install] WantedBy=multi-user.target` i tried it with single quotes, double quotes and no quotes. "start" is the command that kicks the job off so i need it in there. – Mohamed Sharif Apr 23 '22 at 21:00
  • Have you checked permissions of the binary that you are executing? You are starting the service with `sudo` so check that the full path to the binary can be executed with the correct user permissions. – Brendan May 18 '22 at 02:20