If you are SSH-ing to your remote machine and then starting up geth --cache=1024
in the console, when your SSH connection drops out the geth
command will terminate.
You can check if geth
is still running by SSH-ing back to your machine and typing the command ps -ef | grep geth
, for example:
Iota:ESE user$ ps -ef | grep geth
501 37632 879 0 2:36pm ttys001 0:03.31 geth --rpc console
501 37634 2685 0 2:36pm ttys002 0:00.01 grep geth
Once geth
terminates, the geth.ipc
file may be removed depending on whether the application terminates gracefully. This geth.ipc
file is an interprocess communication pipe and not a regular file. Once geth
terminates, the file may still remain on the file system, but other processes cannot communicate to geth
using this pipe.
If geth
terminates without gracefully shutting down, the blockchain data can sometimes (very seldom) be corrupted.
Following is a recipe if you want to keep geth
running on your Ubuntu (assumed from your previous posts) machine. If you want to terminate this background geth
process, use the command killall -q --signal SIGINT geth
.
Recipe For Running geth
Automatically On Startup
If you want geth
to run on your remote machine all the time, here is a recipe, all to be done in the SSH session on your remote machine:
Create a directory for your logs - I'm using $HOME/ethlogs
.
user@RemoteMachine:~$ mkdir $HOME/ethlogs
Create a directory for your log archive - I'm using $HOME/logarchive
.
user@RemoteMachine:~$ mkdir $HOME/logarchive
Create the file $HOME/bin/runGeth
with the following contents:
#!/bin/sh
# Kill geth gracefully
killall -q --signal SIGINT geth
# Wait for geth to be killed gracefully
sleep 30
# Kill viciously if geth is still running
killall -q geth
# Remove the IPC pipe file if it still exists
rm $HOME/.ethereum/geth.ipc
DATE=`date +%Y%m%d_%H%M%S`
# Save old log file into the log archive directory
mv $HOME/ethlogs/geth.log $HOME/logarchive/geth.log_$DATE
# Use 6 for full details
VERBOSITY=3
# Add your geth command line parameters below
geth --cache=1024 --verbosity $VERBOSITY 2>> $HOME/ethlogs/geth.log &
Set the file's executable bit.
chmod 700 $HOME/bin/runGeth
Log out and then log back in so your $HOME/bin path is activated if it has not already been done.
Run geth
user@RemoteMachine:~$ runGeth
If you want geth
to automatically start after you reboot your machine, add the runGeth
command to your /etc/rc.local
file.
user@RemoteMachine:~$ sudo vi /etc/rc.local
and add the following line before the exit 0
:
sudo -u {your username} /home/{your username}/bin/runGeth &
Save and exit the file. Try restarting your computer and use ps -ef | grep geth
to check if geth
is running.