You'll lose cgminer's interactive ui that way.
Practice a little bit of screen manipulation first, then revisit the script.
open two bash terminals
first terminal
screen -dmS miner1
second terminal
screen -x miner1
first terminal
screen -S miner1 -X stuff "/home/pi/git/vthoang/cgminer/cgminer --gekko-2pac-freq 180 -o stratum+tcp://bch.viabtc.com:3333 -u usaminer.2 -p 1 --suggest-diff 64 ^M"
first terminal
pkill cgminer
first terminal
screen -S mine -X stuff "/home/pi/git/vthoang/cgminer/cgminer --gekko-2pac-freq 180 -o stratum+tcp://bch.viabtc.com:3333 -u usaminer.2 -p 1 --suggest-diff 64 ^M"
Very cool, i see it working when i manually input the commands (it seems i had to install screen into raspbian stretch first). Now i will have to make it into a script. Thanks vh!
One question, what does the ^M do at the end of the cgminer configs command? I dont see that in the list of configs for cgminer.