Absurd Minds
http://forums.absurdminds.net/

Bash script to restart server at X time daily
http://forums.absurdminds.net/viewtopic.php?f=58&t=1267
Page 1 of 1

Author:  Amaroq [ 22 Mar 2012 13:36 ]
Post subject:  Bash script to restart server at X time daily

Does anybody know how to make a bash script to kill a server (which is running in a screen) at a certain time every day, then restart that server in the screen?

Author:  jero [ 22 Mar 2012 14:07 ]
Post subject:  Re: Bash script to restart server at X time daily

#!/bin/bash

screen -X -S screenname quit

sleep 10

screen -A -m -d -S screenname ./hl.....blahblah





I think. The shell script would have to be in the same directory, or you would have to change the commands to use /home/gamer/cstrike/hlds........blah blah

Author:  Amaroq [ 22 Mar 2012 15:07 ]
Post subject:  Re: Bash script to restart server at X time daily

What part in there makes it kill at a specific time? Say I'm trying to make it kill at 7am ET (since I bet most people wouldn't be playing at that time)?

Author:  jero [ 22 Mar 2012 16:13 ]
Post subject:  Re: Bash script to restart server at X time daily

Make the script file and run(sh filename.sh) it at with Crontab as well

Author:  Amaroq [ 23 Mar 2012 12:32 ]
Post subject:  Re: Bash script to restart server at X time daily

Ok, so I've made a file called pub.sh
Code:
#!/bin/bash

screen -X -S pub quit

sleep 10

screen -A -m -d -S pub ./hlds_run -game cstrike +ip 70.34.195.6 +port 27018 +maxplayers 21 +map de_dust2 -autoupdate -pingboost 3
Then I did chmod +x pub.sh
(I tested this bash script and it works fine.)

My question now is, am I doing the crontab right?
In /etc/crontab, I put this value to make it restart at 6am daily:
Code:
00 6 * * * gamer /home/gamer/cstrike/pub/pub.sh
Is that correct? Is it correct putting "gamer" in front of the command to run to make sure it runs as gamer and not as root?

Page 1 of 1 All times are UTC-04:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/