genesismining / sgminer-gm

A multi-algo GPU miner
GNU General Public License v3.0
340 stars 146 forks source link

Running sgminer as a cron job #46

Open joker5bb opened 7 years ago

joker5bb commented 7 years ago

Doing sudo crontab -e I add the line below. Checking the log the cron job is executed but no screen session gets created. Running the sgminer command standalone works

47 21 * screen -dmS sgminer /usr/local/bin/sgminer --config ~/sgminer-gm/xmr.conf

int03h commented 7 years ago

Why people use cron to start system jobs is beyond me. Init or systemd are the way to do this. Screen is OK but do a man on byobu .. It uses screen but is WAY better.

If you need to start and stop it at specific times then cron is the right way, but you should still be doing it via service commands rather than running it raw. e.g. systemctl start sgminer in your crontab.

Screen has issues with jobs that are curses based. You should start sgminer in text mode.

I run it as root because it's easier to diagnose and tune. I am aware it's not best practice.

int03h commented 7 years ago

Here's mine :

`#/etc/systemd/system [Unit] Description=SGMiner for Ethereum Mining After=network.target

[Service] Type=simple ExecStart=/bin/sh /root/.sgminer/run_sgminer.sh User=root

Group=root WorkingDirectory=/root/.sgminer

[Install] WantedBy=multi-user.target`

and this is the run script:

`#/root/.sgminer/sgminer.sh

FOR GREATER THAN 4GB GPU USE PTR=1

export GPU_FORCE_64BIT_PTR=1 export GPU_MAX_HEAP_SIZE=100 export GPU_USE_SYNC_OBJECTS=1 export GPU_MAX_ALLOC_PERCENT=100 export GPU_SINGLE_ALLOC_PERCENT=100

/usr/local/bin/sgminer --real-quiet --text-only --remote-config-usecache -c http://192.168.10.5/configs/rack2/sgminer.conf`