4
« on: April 21, 2017, 07:13:58 AM »
Hi everyone,
Today I did a bash script to help me start all the pairs in Linux (one in each screen) with a time delay of 5 seg for each pair. The script check if the screen exist to reduce the risk to start a duplicate pair.
The script will search for all config files in the gunbot folder and will try to start each one.
How to setup:
1) create a file in the gunbot folder with whatever name you want but the extension should be .sh, for example:
nano start_gunbot.sh
2) Copy the code to the file
#!/bin/bash
########### EDIT PLEASE ###############
# exact folder where gunbot and config files are
botfolder="/root/bot/gunbotv2.0.4"
########## NO MORE EDIT ###############
############## DONT EDIT ##############
_dfiles="*-config.js"
red=`tput bold setaf 1`
green=`tput bold setaf 2`
blue=`tput bold setaf 4`
reset=`tput sgr0`
for f in $_dfiles
do
_name="${f##*/}"
_namef="${f%-*}"
echo "Checking if pair $_namef is running..."
if ! screen -list | grep -q "$_namef"; then
echo "${red}Pair not running.... ${green}Starting $_namef pair... ${reset}"
screen -dmS $_namef
screen -S $_namef -p 0 -X exec $botfolder/gunbot $_namef
echo "Waiting 5S"
sleep 1
echo -n "...1"
sleep 1
echo -n "...2"
sleep 1
echo -n "...3"
sleep 1
echo -n "...4"
sleep 1
echo "${blue}...5!${reset}"
echo "${green}Next PAIR${reset}"
else
echo "${green}Pair $_namef RUNNING${reset}"
sleep 0.2
fi
done
3)Make sure you edit the botfolder variable to the exact folder your bot is installed.
4) control + o to save and control + x to exit
5) make in executable:
chmod u+x start_gunbot.sh
6) execute the script
./start_gunbot.sh
The script will search for all files with the name XXX_XXX-config.js and will execute the bot with that configuration in a screen called with the name of the pair.
Remember that:
- You should have only the config files you want to run in the gunbot folder, because the script will start ALL the pairs with config files in that directory. If you don't want to run a individual pair, move the config file.
- This only works with gunbot strategy, not 1000 strategy. It's easy to modify for that strategy.
- Dont call this script if you already running the bot. To run this script please stop all your robot sessions.
- Works with all Linux distributions.
If you want to see the output of each pair, you should execute:
screen -ls
and when you find the pair you want to see the output, only call the screen:
screen -r PAIR_NAME
To exit of the screen without closing it, press:
control a + d
I have another script to stop all trading, here is the code:
#!/bin/bash
############## DONT EDIT ##############
_dfiles="*-config.js"
red=`tput bold setaf 1`
green=`tput bold setaf 2`
blue=`tput bold setaf 4`
reset=`tput sgr0`
for f in $_dfiles
do
_name="${f##*/}"
_namef="${f%-*}"
echo "Checking if pair $_namef is running..."
if ! screen -list | grep -q "$_namef"; then
echo "${blue}Pair not running.... ${reset}"
else
echo "${red}Pair $_namef RUNNING${reset}"
screen -S $_namef -X quit
echo "${blue}EXITING...${reset}"
sleep 0.2
fi
done
This code will close all the screen running with the name of the pairs listed in the gunbot folder.
If anyone want help, let me know,
If this helps you, give me a beer:
1Hoy4BgkHQg8wGzskwcVbxhcEcRscMFRnW
Thanks.