• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Linux Auto restarter?

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,764
Solutions
1
Reaction score
227
Location
Chile, Santiago
How to create a restarter that checks if the process is on, it is isn't, it run the server... maybe a crontab? Any ideas or suggestions?

- - - Updated - - -

BUMP?
 
You can also add this code to cron (run it every 30 or 60 minutes). I didn't test it but it should work well.
Code:
#!/bin/bash
if [ "$(pidof forgottenserver)" ] 
then
  # process was found
else
  # process not found
  ./forgottenserver 
fi


_
Regards,
sn3ejk
 
snejk I like your crontab, but pidof reads the process name right? And ./forottenserver should first do a cd to the directory?
I'm not sure that I understand you correctly (so sorry about it but I got lacks in English). You don't have to use command "cd". You can create shortcut to your executable file - example:
Code:
ln -s /home/kito2/forgottenserver/forgottenserver /usr/bin/forgottenserver
And you have also update your script to this one:
Code:
#!/bin/bash
if [ "$(pidof forgottenserver)" ]
then
  # process was found
else
  # process not found
  forgottenserver
fi


_
Regards,
sn3ejk
 
I'm not sure what you're guys are doing or talking about, but if you want a server to restart if the server closes, in Linux, use command:
while true; do ./tfs; done
 
Well go to your Filezilla or Winscp and make 1 file name:
restarter.sh
now inside put this script:
Code:
#!/bin/bash
ulimit -c unlimited
while true; do
        cd /home/server
        ./theforgottenserver
        sleep 5
done

Edit: cd /home/server <- for where are your theforgottenserver in your dedicated.
now in putty give
chmod -R 777 restarter.sh
and remember: for start your server don't use more
./theforgottenserver
now use
./restarter.sh
or
./rest*

is same :p
 
Well go to your Filezilla or Winscp and make 1 file name:
restarter.sh
now inside put this script:
Code:
#!/bin/bash
ulimit -c unlimited
while true; do
        cd /home/server
        ./theforgottenserver
        sleep 5
done

Edit: cd /home/server <- for where are your theforgottenserver in your dedicated.
now in putty give
chmod -R 777 restarter.sh
and remember: for start your server don't use more
./theforgottenserver
now use
./restarter.sh
or
./rest*

is same :p

But how it works Cronox? Cause I try to understand it and can't get it... while true; do... but it shouldn't be while false? Since it would return a false if the process isn't running? And also how it check if the process is running... I mean it wouldn't open multiple times the server?
 
But how it works Cronox? Cause I try to understand it and can't get it... while true; do... but it shouldn't be while false? Since it would return a false if the process isn't running? And also how it check if the process is running... I mean it wouldn't open multiple times the server?

cut all the bullcrap, do what I told you.
go to the dest folder

cd /var/theforgottenserver or whatever the server is.
do the command:
while true; do ./tfs done.
and then leave the window open at all times... the server will restart itself if it crash or shuts down or whatever happens that make the server go offline.
just try it... don't create 10000 of other shits when you can do the same thing with 1 line of simple code.
 
Back
Top