Running Sendmytip.sh script as a Cronjob

I am trying to run sendmytip.sh script as a cron job but I get the error saying:

line53: shelley: command not found

edited the script a little and realized, the command: cardano-cli shelley query tip --mainnet does not execute and can not be found. I dug into the crontab and realized, it’s running my the script in a restricted environment hence why cardano-cli commands can not be executed. But my question is, how do I provide a suitable path for cardano-cli commands to run in cron?

This article here under section: Cron runs your command in a restricted environment helped tremendously.

Attached is a screenshot of the error from crontab running sendmytip.sh script.
Screen Shot 2020-10-18 at 10.29.46 AM

Hello,

There is no need to run this as a cron - run it as a systemd service instead and the reported tip will not lag.

@w0lverin3 in your crontab you would need to redefine any environment variables relied upon by your script as cron doesn’t have access to them.

Slots are only 1s. What frequency were you planning on running the cron?

Hi @ADAfrog,

I hope this finds you well. I realise this comes a bit late, but I had a question precisely about running sendmytip.sh as a systemd service. When I run the script from the console, it has no dramas finding the socket environment variable. I setup a systemd unit as follows:

[Unit]
Description=Pooltool.io sendmytip service
After=network.target

[Service]
Type=simple
User=spuser
WorkingDirectory=/home/spuser
ExecStart=/bin/bash /home/spuser/shelley-sendmytip.sh

[Install]
WantedBy=multi-user.target

When I start the service, I get an error saying that cardano-cli was unable to locate the socket, like so:

Shelley command failed: query tip Error: Error while looking up environment variable: CARDANO_NODE_SOCKET_PATH Error: “CARDANO_NODE_SOCKET_PATH”

I find this strange, as I also run the cardano-node as a systemd service, and have had no issues with it not finding the environment variable. I have tried to change the sendmytip.sh script to point at the socket directly, but that has not fixed the problem.

I have also noted two more things:

  1. my propagation times are consistently the slowest of the bunch on pooltool (when I manage to run sendmytip). Will this improve as I work on my topology files?

  2. if I run the sendmytip script and put it in the background, it keeps running, but it will not send data to pooltool (eg, my tip stops being updated). Why is that?

Any help is greatly appreciated,

Cheers,
A