Use this script to schedule all of your NiceHash Miner(s) to turn on and off at certain times of the day.
Electricity costs between 4-9pm are high in my area and I want NiceHash to stop mining during those times. This script should start and stop your rigs on a schedule.
Setting up this scheduling process could take up to 1 hour depending on your skill level
Acquire the necessary files by downloading the latest release. Save and extract the files to a directory of your choosing or download using your preferred method.
-
Open the NiceHash API key settings. Take note of your organization id located at the top of the page. (Ex. 01234567-0123-0123-0123-012345678900)
-
Create an API key. You can make the App Name whatever you want. I recommend changing the API permissions to
only
allow "Mining permissions" and "Manage Rigs" as this is all that is required for the script to function. Take note of the "API Key Code" (public key) and the "API Secret Key Code" (private key). Make sure you complete the process of activating the new API key. -
Put the
public api key
,private api key
andorganization id
into their respective locations inside config.json
- Install Visual Studio Code
- Go to plugins and install python or follow these instructions (https://www.geeksforgeeks.org/download-and-install-python-3-latest-version/)
- Install Pip (https://www.geeksforgeeks.org/how-to-install-pip-on-windows/)
- Use pip to install requests (https://docs.python-requests.org/en/master/user/install/)
- Install Visual Studio Code
- Go to plugins and install python
- Install Pip (https://www.geeksforgeeks.org/how-to-install-pip-in-macos/)
- Use pip to install requests (https://docs.python-requests.org/en/master/user/install/)
Run the test_api.py
script before setting up the Windows Task Scheduler or Cron job.
Using a shell of your choice (terminal, cmd) navigate to the directory where test_api.py
is located and type python test_api.py
(for Windows) or python3 test_api.py
(for MAC).
If it worked then you should see a list of your rigs and then 'Finished' at the bottom.
If it didn't work then read the error messages and troubleshoot.
- Make sure the inital testing works
- Go to https://www.nicehash.com/my/mining/rigs and determine whether your rigs are mining or stopped
- Open a terminal/cmd prompt to the
root folder
of this project - If they are stopped, run
python start_mining.py
(Windows)python3 start_mining.py
(MAC), refresh the rigs page and they should start - If they are mining, run
python3 start_mining.py
(Windows)python3 stop_mining.py
(MAC), refresh the rigs page and they should stop
-
Using my custom instructions for
Windows
Task Scheduler -
Using
CronTab
(not tested yet
):
If you would like to run this script on your own schedule using crontab, you can pass '--cron' as a command line argument. Passing this argument will suppress the automatic 4 hour loop, and the script will only execute once.
You can use Crontab Generator to quickly generate a custom crontab command.
Note: Crontab runs in your home directory by default. If you saved the script to a different directory, you will have to tell cron to change directories before running the script.
Ex:
* */4 * * * cd /home/[USER]/NiceHash-Windows-Scheduler && python3 start_schedule.py --cron >/dev/null 2>&1
* */4 * * * cd /home/[USER]/NiceHash-Windows-Scheduler && python3 stop_schedule.py --cron >/dev/null 2>&1