2

I'm trying to start a service which runs this script, which is just flags for a binary file

This is the script:

./geth_linux --config ./config.toml --datadir ./mainnet --cache 100000 \
             --rpc.allow-unprotected-txs --txlookuplimit 0 --http --ws \
             --maxpeers 100 --syncmode=snap --snapshot=false --diffsync

When I run this script in terminal from the binary's directory /home/bsc, it runs as I want it to.

When I start the service though, I get this error:

(code=exited, status=203/EXEC)

Here is my .service file:

[Unit]
Description=BSC Full Node
[Service]
User=bsc
Type=simple
WorkingDirectory=/home/bsc
ExecStart=/home/bsc/start.sh
Restart=on-failure
RestartSec=5
[Install]
WantedBy=default.target

I have made this script executable with:

chmod +x /home/bsc/start.sh

Also i have run:

chown +R bsc.bsc /home/bsc/*

I also tried running ExecStart=/bin/bash /home/bsc/start.sh and also adding #!/bin/bash at the top line of the script but failed also.

I'm stumped.

Ubuntu 20.04.3 LTS

systemd error log

Nov 24 04:25:14 rezonautik systemd[1]: Started BSC Full Node.
Nov 24 04:25:14 rezonautik bash[26939]: /home/bsc/start.sh: line 1: geth: command not found
Nov 24 04:25:14 rezonautik systemd[1]: bsc.service: Main process exited, code=exited, status=127/n/a
Nov 24 04:25:14 rezonautik systemd[1]: bsc.service: Failed with result 'exit-code'.
Nov 24 04:25:19 rezonautik systemd[1]: bsc.service: Scheduled restart job, restart counter is at 1.
Nov 24 04:25:19 rezonautik systemd[1]: Stopped BSC Full Node.
Nov 24 04:25:19 rezonautik systemd[1]: Started BSC Full Node.
Nov 24 04:25:19 rezonautik bash[26981]: /home/bsc/start.sh: line 1: geth: command not found
Nov 24 04:25:19 rezonautik systemd[1]: bsc.service: Main process exited, code=exited, status=127/n/a
24
  • Change the call to /usr/bin/strace -f ./geth_linux ... 2>&1 and add the (last 30 lines of the) output (systemctl status servicename -n 40) to your question (or use strace -o /path/to/filename for dumping the output to a file). Nov 27, 2021 at 16:35
  • sorry for my ignorance, when you say change the call do you mean to make this the ExecStart information?
    – niXon
    Nov 27, 2021 at 16:41
  • No. SystemD does not understand shell stuff like redirections so that has to be put in the script which SystemD starts. Nov 27, 2021 at 16:43
  • do i add this information as a new line above my original line?
    – niXon
    Nov 27, 2021 at 16:44
  • 2
    Can you provide please the ./geth_linux script contents? I'm asking because of /home/bsc/start.sh: line 1: geth: command not found error, which mentions geth (without the "linux" part) and I have a feeling this is some kind of a PATH problem.
    – Evengard
    Nov 27, 2021 at 20:12

3 Answers 3

0

There is a path problem (and a general inconsistency in your description).

In your description the script /home/bsc/start.sh starts with ./geth_linux but it should start with a shebang line.

The error message says line 1: geth: command not found. It neither says geth_linux nor ./geth_linux. So there is obviously some mix up.

You should use only the following command calls:

  • full path e.g. /home/bsc/start.sh (that is the best solution)
  • no path i.e. geth_linux instead of ./geth_linux; this only works for commands for which the command which outputs the absolute file path.
10
  • all of these scenarios output the same issue: geth: command not found. it doesn't matter if i put shebang as the first line in the script, it doesn't matter whether i put ./geth_linux or also just geth_linux as the call in the script. same output
    – niXon
    Nov 28, 2021 at 1:10
  • i have also tried ExecStart=/bin/bash /home/bsc/start.sh
    – niXon
    Nov 28, 2021 at 1:10
  • The error message says line 1: geth: command not found. It neither says geth_linux nor ./geth_linux. So there is obviously some mix up. guaranteed within the script it is geth_linux. is it possible that i'm looking at old errors? before each attempt anytime i modified the systemd file i ran daemon-reload, and reset-failed..
    – niXon
    Nov 28, 2021 at 1:21
  • It seems geth_linux is not a binary but another script. And that script contains a call to geth which is not in the $PATH. Do what I told you to do: Use full paths in all the scripts (except for well known commands). Nov 28, 2021 at 1:23
  • in .service file i have ExecStart=/home/bsc/start.sh. in start.sh i have shebang as line1, then line2 /home/bsc/geth_linux then all my flags. Same error is returned
    – niXon
    Nov 28, 2021 at 1:40
0

The service file is look working fine. I highly move your script file as following directory:

mv ./YOUR_CURRENT_PATH /usr/local/bin/

Then the geth_linux linux will be accessible from everywhere.

-1

ok, i figured this out. the problem was bsc.service had to be renamed to geth.service. after making this change everything works

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .