Absurd Minds

More than 100 years without a motto.
It is currently 28 Mar 2024 08:28

All times are UTC-04:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: 22 Mar 2012 13:36 
Offline
User avatar

Joined: 25 Mar 2010 19:07
Posts: 8392
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?

_________________
Server list
Donate


Top
   
PostPosted: 22 Mar 2012 14:07 
Offline
User avatar

Joined: 25 Feb 2012 19:18
Posts: 908
Location: Ontario, Canada
#!/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

_________________
Image


Top
   
PostPosted: 22 Mar 2012 15:07 
Offline
User avatar

Joined: 25 Mar 2010 19:07
Posts: 8392
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)?

_________________
Server list
Donate


Top
   
PostPosted: 22 Mar 2012 16:13 
Offline
User avatar

Joined: 25 Feb 2012 19:18
Posts: 908
Location: Ontario, Canada
Make the script file and run(sh filename.sh) it at with Crontab as well

_________________
Image


Top
   
PostPosted: 23 Mar 2012 12:32 
Offline
User avatar

Joined: 25 Mar 2010 19:07
Posts: 8392
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?

_________________
Server list
Donate


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC-04:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited