canontech / staking-payouts

CLI to make staking payout transactions for Substrate FRAME-based chains

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

receiving error when bashed with crontab

hitchhooker opened this issue · comments

payouts.sh:
node /home/user/staking-payouts/build/index.js -w wss://kusama-rpc.polkadot.io \ --stashesFile /home/user/stashes.json \ --suriFile /home/user/key.txt
crontab -l
* * * * * source ~/.bashrc; bash /home/user/payout.sh > /home/user/crontab.payouts.bbq 2>&1
crontab.payouts.bbq:
/home/user/staking-payouts/node_modules/@polkadot/api/index.js:3 import "./detectPackage.js"; ^^^^^^^^^^^^^^^^^^^^ SyntaxError: Unexpected string at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.<anonymous> (/home/user/staking-payouts/build/index.js:7:15) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

im receiving following error when trying to use staking-payouts with crontab. works fine tho when bashed without crontab. cant figure out what i am doing wrong here. added bashrc sourcing since somebody mention it at the validator support. crontab is being run as a same user.

Tried also installing staking-payouts with npm but seems like it did not make payouts command to be found on arch linux and ubuntu.

only workaround I managed to find was to run staking-payouts inside docker and then call docker with crontab.

sudo crontab -e
0 */6 * * * docker run payouts -w wss://kusama-rpc.polkadot.io -s wallet_address -u ./wallet_key.txt -e 8 > /home/user/crontab.logs.docker 2>&1

This error is from using older versions of node (at least every time I have seen it).

You need to make sure the script is using node version 14 or above. Maybe the script is using a different node binary then when you when you call it directly in the terminal?