GUNBOT: The automatic profit generator > Beginners & Help

[TUT] Script for easy-delayed-start of all pairs in Linux

(1/3) > >>

shacky:
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:

--- Code: ---nano start_gunbot.sh
--- End code ---
2) Copy the code to the file

--- Code: ---#!/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
--- End code ---
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:

--- Code: ---chmod u+x start_gunbot.sh
--- End code ---
6) execute the script

--- Code: ---./start_gunbot.sh
--- End code ---

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:

--- Code: ---screen -ls
--- End code ---

and when you find the pair you want to see the output, only call the screen:

--- Code: ---screen -r PAIR_NAME
--- End code ---

To exit of the screen without closing it, press:
control a + d

I have another script to stop all trading, here is the code:


--- 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
--- End code ---

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.

jroddingham:
That sir, is some sexy bash. Mine is just a line of commands. Yours is smart. I'm gonna go drink some Brawndo now. It's got electrolytes.

playmobitch:
hi

little improvement and compatibility with 3.x release :


change the grep command line to grep -qw (because pair like STR won't launch if pair STRAT is already running so the -w flag force a whole word match)


--- Code: ---#!/bin/bash
########### EDIT PLEASE ###############
# exact folder where gunbot and config files are
botfolder="/home/user/gunbot"
########## 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 -qw "$_namef"; then
  echo "${red}Pair not running.... ${green}Starting $_namef pair... ${reset}"
  screen -dmS $_namef
  screen -S $_namef -p 0 -X exec node $botfolder/index $_namef poloniex
  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
--- End code ---

dobcrypto:
Will it work if I have 2 folders of bot,
1 - I run mannualy and to 1 polo acc.
2 - I run with your start.sh to 2 polo acc?
Or I need to run only one of bot copy?

shacky:
This scripts work for you, if you have two polo accounts in two folders without problem. You should change only;

                screen -dmS $_namef to screen -dmS $_namef-2dary
if ! screen -list | grep -qw "$_namef"; then to if ! screen -list | grep -qw "$_namef-2dary"; then

I suggets to you, to have one script for each folder and everything will work.

Navigation

[0] Message Index

[#] Next page

Go to full version