If you’re asking if you can set automatic restarts at certain times, then yes, as mentioned by the OP, you would use a cron job to set automatic restarts. You can set that cronjob to restart as often and at the times you want.
If you’re instead asking about how long the restart pauses prior to it’s restart, yes, just add more sleeps to that function.
Did you try your own script or you just posted it?
Screen stuff commands are broken and the way you resume screens is weird.
Add more conditions maybe? Dynamic timer? You could do much better
Author pretty much stated he’s going to set it and forget it in regards to this script but I’d love to hear what changes you’d implement since I’m using the script. It’s working fine for us but would be interested in hearing what changes or improvements you’d make and why.
I have my own script,
I will share it when i finish some editing (trying to make it user input compatible since i want to share it), maybe in 1 or 2 hours.
I was using this script on my debian server, so yes.
I just shared a script with the knowledge I had. If you are not happy, nothing prevents you from doing yours and sharing it.
Any script can be embellished. It just depends on the person
So unpleasant people like you …
Happy about what? I don’t even use your script
That was my own opinion, i wrote some stuff you could use to improve your script but i deleted them because you don’t deserve it or even this reply.
As much as I love to see useful threads devolve into toxic I-know-you-are-but-what-am-I tennis matches, I just wanted to say Hal, script’s working great for our server. I really appreciate you taking the time and effort to share it.
I would like to share my edit of the script.
I add “pkill -9 ld-musl-x86” after the command to kill screen because sometimes it doesn’t kill fivem process when restart and also I edited colours ready for PHP output for some private Server manager tab for admins.
#!/bin/bash
WIT="\033[0;39m"
ROOD="\033[1;31m"
GROEN="\033[1;32m"
GEEL="\033[1;33m"
PAARS="\033[1;35m"
LOL="\033[1;36m"
MSG_180="Une temp.te approche, dans 3 minutes la ville sera rasé !"
MSG_60="Une temp.te est aux portes de la ville, fuyez pauvres fous !"
MSG_30="Mon dieu !! Dans 30 secondes vous serez tous morts si vous ne fuyez pas !"
FIVEM_PATH=/home/username/FiveM
SCREEN="TheBalkanRP-SRV01-test"
cd $FIVEM_PATH
running(){
if ! screen -list | grep -q "$SCREEN"
then
return 1
else
return 0
fi
}
case "$1" in
# -----------------[ Start ]----------------- #
start)
if ( running )
then
echo -e ""
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:green"> $SCREEN <span style="color:orange"> SERVER IS ALREADY RUNNING!!"
echo -e ""
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> STOP THE SERVER FIRST!"
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> OR"
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:green"> RESTART SERVER!"
sleep 2
else
echo -e ""
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> STARTING THE <span style="color:green">$SCREEN<span style="color:orange"> SERVER "
screen -dm -S $SCREEN
sleep 2
screen -x $SCREEN -X stuff "cd /home/username/FiveM/server-data && bash /home/username/FiveM/run.sh +exec server.cfg > /home/username/public_html/output.txt
"
sleep 20
screen -x $SCREEN -X stuff "restart sessionmanager
"
echo -e "<span style="color:blue">BOT<span style="color:red">: <span style="color:green"> $SCREEN<span style="color:orange"> SERVER HAS STARTED!"
sleep 2
fi
;;
# -----------------[ Stop ]------------------ #
stop)
if ( running )
then
echo -e ""
echo -e "<span style="color:blue">BOT<span style="color:red">: <span style="color:blue">STOPPING THE <span style="color:green"> $SCREEN<span style="color:orange"> SERVER"
screen -S $SCREEN -p 0 -X stuff "`printf "say $MSG_30\r"`";sleep 10
screen -S $SCREEN -X quit
sleep 5
pkill -9 ld-musl-x86
sleep 5
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> THE <span style="color:green">$SCREEN<span style="color:orange"> SERVER HAS STOPPED"
sleep 5
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> REMOVING CACHE FOLDER"
rm -R /home/username/FiveM/server-data/cache/
rm -rf /home/username/public_html/output.txt
sleep 5
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> CACHE FOLDER HAS BEEN REMOVED!"
sleep 5
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> THE <span style="color:green"> $SCREEN<span style="color:orange"> SERVER <span style="color:red">HAS STOPPED!"
sleep 2
else
echo -e ""
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> THE <span style="color:green"> $SCREEN SERVER <span style="color:red">IS NOT RUNNING!!!"
echo -e ""
# echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> USE THE COMMAND: $GEEL./manage.sh start $WIT"
sleep 2
fi
;;
# ----------------[ Restart ]---------------- #
restart)
if ( running )
then
echo -e ""
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> THE <span style="color:green">$SCREEN <span style="color:orange">SERVER <span style="color:green"> WAS RUNNING"
sleep 5
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> STOPPING THE <span style="color:green"> $SCREEN<span style="color:orange"> SERVER"
screen -S $SCREEN -p 0 -X stuff "`printf "say $MSG_30\r"`"; sleep 10
screen -S $SCREEN -X quit
sleep 5
pkill -9 ld-musl-x86
sleep 5
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:green"> $SCREEN <span style="color:orange">SERVER HAS STOPPED "
sleep 5
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> REMOVING CACHE FOLDER"
rm -R /home/username/FiveM/server-data/cache/
rm -rf /home/username/public_html/output.txt
sleep 5
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> CACHE FOLDER HAS BEEN REMOVED!"
sleep 5
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> STARTING THE <span style="color:green"> $SCREEN <span style="color:orange">SERVER"
screen -dm -S $SCREEN
sleep 5
screen -x $SCREEN -X stuff "cd /home/thebalk/FiveM/server-data && bash /home/username/FiveM/run.sh +exec server.cfg > /home/username/public_html/output.txt
"
sleep 20
screen -x $SCREEN -X stuff "restart sessionmanager
"
else
echo -e ""
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> THE <span style="color:green">$SCREEN<span style="color:orange"> SERVER IS NOT RUNNING"
sleep 5
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:orange"> STARTING THE <span style="color:green"> $SCREEN<span style="color:orange"> SERVER "
screen -dm -S $SCREEN
sleep 5
screen -x $SCREEN -X stuff "cd /home/fivem/FiveM/server-data && bash /home/username/FiveM/run.sh +exec server.cfg > /home/username/public_html/output.txt
"
sleep 20
screen -x $SCREEN -X stuff "restart sessionmanager
"
fi
echo -e "<span style="color:blue">BOT<span style="color:red">:<span style="color:green"> SERVER HAS STARTED!"
sleep 2
;;
# -----------------[ Status ]---------------- #
status)
if ( running )
then
echo -e "<span style="color:blue">THE <span style="color:green"> $SCREEN<span style="color:blue"> SERVER <span style="color:green">IS RUNNING!"
else
echo -e "<span style="color:blue">THE <span style="color:green"> $SCREEN <span style="color:blue"> SERVER<span style="color:red"> IS NOT RUNNING!"
fi
;;
# -----------------[ Screen ]---------------- #
screen)
echo -e "$GROEN Server screen [$SCREEN]. $WIT"
screen -R $SCREEN
;;
*)
echo -e "$GEEL Use: $WIT ./manage.sh {start|stop|status|screen|restart}"
exit 1
;;
esac
exit 0
Hello, I have a problem.
When I start my server with the command ./manage.sh start
this error message comes along: There is no screen that can be attached to DragonRP.
please help me…