PokemonGoBot icon indicating copy to clipboard operation
PokemonGoBot copied to clipboard

Possible to automate restart of console/terminal after 1 1/2 hours?

Open pedda007 opened this issue 10 years ago • 25 comments

hi! just wanted to aski if it is possible to restart automatically the terminal or console after 1 1/2 hours? Anybody tried something like that?

Thanks!

pedda007 avatar Aug 08 '16 13:08 pedda007

Hi, I'm using this bash code:

#!/bin/bash while [ 1 ]; do killall java; java -jar PokemonGoBot-0.5.0.jar & sleep 5400; done

chemikaz avatar Aug 08 '16 13:08 chemikaz

only issue you will have is on the restart, it will teleport to the start, if thats far from the end when it shut off, then it will soft ban

i use this as a auto off timer..

make a bat script to start the bot, called run.bat, use this as the timer, you need to start the bot with this script for it to work..

start "pogo" run.bat timeout /t 2400 taskkill /fi "WINDOWTITLE eq pogo_" /f taskkill /fi "WINDOWTITLE eq pogo_" /f taskkill /fi "WINDOWTITLE eq pogo*" /f

the number is seconds, 2400 = 40min

i use 3 taskkills because when i used 1 it didnt always kill it...

russr123 avatar Aug 08 '16 13:08 russr123

That's true if you are on mac and use my script you can add: "sleep 600;" after "killall java;" So you will get 10min gap before teleport back to the star;]

chemikaz avatar Aug 08 '16 13:08 chemikaz

Thanks guys for your answers. I'm on mac and i have completely no idea, how i do it. I'm really sorry for such newbie questions. But how do i do that things? Do i have to make an extra file for that? Or just to type that things in the terminal? Thanks

pedda007 avatar Aug 08 '16 13:08 pedda007

Create new file "script.sh" in same directory where is jar file. Copy this lines in to that file:

#!/bin/bash while [ 1 ]; do java -jar PokemonGoBot-0.5.0.jar & sleep 5400; killall java; sleep 600; done

Make your file executable chmod +x script.sh Run your script: ./script.sh

chemikaz avatar Aug 08 '16 13:08 chemikaz

Sorry guys, i dont get it. I wrote these exact lines in the text edit and saved it as script2.sh. I add a screenshot where you see the script file and then the terminal "output", or how you call it xD Maybe you can help me out one more time :)

thaaaanks bildschirmfoto 2016-08-08 um 16 26 49

pedda007 avatar Aug 08 '16 14:08 pedda007

My solution is cron + bash script. It restarts the bot in every 2 hours.

$ crontab -l

# m h  dom mon dow   command
0 */2 * * * bash /home/urbalazs/bot-restart.sh

$ cat bot-restart.sh

#!/bin/bash

killall java
sleep 10
cd /home/urbalazs/PokemonGoBot
java -jar PokemonGoBot-0.5.0.jar --spring.main.web-environment=false >> log-`date +'%Y%m%d'`.txt &

The bot logs its activity to a file. It creates a new file every day, like: log-20160808.txt

urbalazs avatar Aug 08 '16 14:08 urbalazs

This is my script. Runs between 7am and 8pm. Runs between 20 to 40 mins. Pauses 10 to 15 mins. Takes random breaks.

2 batch files -

run.bat

@echo off
setlocal enableextensions disabledelayedexpansion
TITLE pogoscrapper-controller

:loop
set "now=%time: =0%"
echo %now%
set "task=runbot"
if "%now%" geq "20:00:00,00" ( set "task=idlebot" )
if "%now%" lss "07:00:00,00" ( set "task=idlebot" )
echo Task is %task%

SET /A randvar=%RANDOM%
echo Random var - %randvar%
set thrushold=25000
if %randvar% geq %thrushold% ( 
echo "skipping"
goto task_idlebot
)
call :task_%task%

:task_runbot
start /min runpogo.bat
SET /A seconds=%RANDOM% * 1200 / 32768 + 1200
timeout /t %seconds%
taskkill /f /FI "WINDOWTITLE eq running-pogoscrapper" /T

:task_idlebot
SET /A seconds=%RANDOM% * 600 / 32768 + 300
timeout /t %seconds%
goto loop

runpogo.bat

TITLE running-pogoscrapper
"C:\Program Files\Java\jre1.8.0_101\bin\java.exe" -jar PokemonGoBot-0.5.0.jar
pause

vamirineni87 avatar Aug 08 '16 14:08 vamirineni87

pedda007, have you added last line where is word "done" ?

chemikaz avatar Aug 08 '16 15:08 chemikaz

i added this word in this second.... now it WORKS!!!! Thank you very much! But when does the relog come? In 10 minutes? Because i waited 10min and it didn't restart...

pedda007 avatar Aug 08 '16 15:08 pedda007

Its will be running for 90min then pausing for 10min and restarts;]

chemikaz avatar Aug 08 '16 16:08 chemikaz

@chemikaz how can I bring this to work when I'm using the "source" and not the prebuild on OSX? This way?

#!/bin/bash
while [ 1 ]; do
./gradlew run & sleep 5400;
killall java;
sleep 600;
done

I'm getting everything started - just wanna make sure it will work in 1,5hours ;)

pet90210 avatar Aug 08 '16 17:08 pet90210

I think it should work. Let me know after 1,5hr :)

chemikaz avatar Aug 08 '16 17:08 chemikaz

@chemikaz - I'll report ;)

pet90210 avatar Aug 08 '16 17:08 pet90210

hi @chemikaz after 1.5 hours it not works

zhoushifeng8 avatar Aug 08 '16 18:08 zhoushifeng8

@zhoushifeng8 should be 10min pause before restart.

chemikaz avatar Aug 08 '16 19:08 chemikaz

@chemikaz wait 30mins and not restart...

zhoushifeng8 avatar Aug 08 '16 19:08 zhoushifeng8

didn't work either ... could not kill the javaprocess with one time :/

pet90210 avatar Aug 08 '16 19:08 pet90210

Can someone make a video tutorial for us rookies?

yscphdk avatar Aug 08 '16 19:08 yscphdk

urbalazs, It works great, I've simply changed the sleep time to 600 to avoid softbans.

BugSyst3m avatar Aug 08 '16 20:08 BugSyst3m