iquidus / explorer

An open source block explorer
BSD 3-Clause "New" or "Revised" License
747 stars 1.33k forks source link

Cronjob not working #468

Closed suzandi closed 3 years ago

suzandi commented 3 years ago

Hello,

After installing the script, updating the database, the blockchain is synced, but the cronjobs won't run or run but not working, there is no error in debug or cronjob error log, I can only update the index if I manually type:

node scripts/sync.js index update.

Is there any resolvation?

joeuhren commented 3 years ago

In most cases, you must specify the full path to both the explorer and node.js in a cron job. A cmd like node scripts/sync.js index update will not work in crontab because of the incomplete paths. If you don't know where your node.js is installed, you can run the cmd which node to find the node path.

Example paths: Explorer: /home/username/explorer node: /home/username/.nvm/versions/node/v14.16.1/bin/node

Given the sample paths above, the index update cmd would look like this:

*/1 * * * * cd /home/username/explorer && /home/username/.nvm/versions/node/v14.16.1/bin/node scripts/sync.js index update > /dev/null 2>&1

Hopefully that helps point you in the right direction.

uaktags commented 3 years ago

I agree with Joe.

Perhaps provide what your cronjob is. In the readme we also provide that you should use the path to node /usr/bin/node.

suzandi commented 3 years ago

Stupid me. Somehow when the first time I installed it, it works with this crontab example:

/1 * cd explorer && /usr/bin/nodejs scripts/sync.js index update > /dev/null 2>&1

But my node now was on another location. Doing which node to find the location and changing on the crontab completely solve the issue!

Many thanks guys!

pacman809 commented 3 years ago

Close the issue?

suzandi commented 3 years ago

Yes please, many thanks!