Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Timed ssh script?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
ps2cho
Apprentice
Apprentice


Joined: 27 Jun 2005
Posts: 196

PostPosted: Mon Aug 28, 2006 5:30 pm    Post subject: Timed ssh script? Reply with quote

Ok guys heres the deal...

On my server that i host for counter-strike i want it to restart the program at like 3:30am every day.
Is there some way to do this?
_________________
Toshiba Satellite A45-S121 - 2.8GHz Celeron @3.2GHz // 512MB RAM // OnBoard VGA // WLAN
==
Athlon XP 2000+ @ 2.2GHz // 768MB PC2700 @ 177FSB // eVGA 6600GT // 60GB Maxtor
Back to top
View user's profile Send private message
Teetante
Guru
Guru


Joined: 02 Mar 2004
Posts: 515
Location: Oldenburg/Germany

PostPosted: Mon Aug 28, 2006 5:50 pm    Post subject: Reply with quote

why not use a cronjob on the server?
_________________
ICQ #81510866 - http://the-gay-bar.com - MSN tante@emptiness.de
Occam's Razor:
-"Entia non sunt multiplicanda praeter necessitatem."-
Back to top
View user's profile Send private message
ps2cho
Apprentice
Apprentice


Joined: 27 Jun 2005
Posts: 196

PostPosted: Mon Aug 28, 2006 6:53 pm    Post subject: Reply with quote

im not sure how to do that
_________________
Toshiba Satellite A45-S121 - 2.8GHz Celeron @3.2GHz // 512MB RAM // OnBoard VGA // WLAN
==
Athlon XP 2000+ @ 2.2GHz // 768MB PC2700 @ 177FSB // eVGA 6600GT // 60GB Maxtor
Back to top
View user's profile Send private message
Teetante
Guru
Guru


Joined: 02 Mar 2004
Posts: 515
Location: Oldenburg/Germany

PostPosted: Mon Aug 28, 2006 6:57 pm    Post subject: Reply with quote

Look at
Gentoo Linux Cron Guide and
Gentoo Wiki: How to use Cron for a few examples.
_________________
ICQ #81510866 - http://the-gay-bar.com - MSN tante@emptiness.de
Occam's Razor:
-"Entia non sunt multiplicanda praeter necessitatem."-
Back to top
View user's profile Send private message
tlailax
Apprentice
Apprentice


Joined: 22 Feb 2004
Posts: 187

PostPosted: Mon Aug 28, 2006 6:58 pm    Post subject: Reply with quote

as the user running the job :
Code:
crontab -e

will open your editor.
the format is (read the man page for crontab):
Code:
<minute> <hour> <day> <month> <day of week> <command>

with allowed formats n-m (range) a,b,c (specific numbers) and * for any
example
Code:
0 0,12 * * 1-4 /scripts/backup.sh

will run a backup.sh script at 0:00 and 12:00 on monday through thursday of every week.
_________________
(\ /)
(O.o)
(> <)
This is Bunny. Copy Bunny into your signature to help him on his way to world domination
Back to top
View user's profile Send private message
ps2cho
Apprentice
Apprentice


Joined: 27 Jun 2005
Posts: 196

PostPosted: Tue Aug 29, 2006 12:15 am    Post subject: Reply with quote

what about if i wanted to have the server console say something to the users?

Here is an example:

3:25AM -- Server says to any players playing "The Server will be restarted to ensure optimal performance in 5minutes time. Thank you for playing"

3:30AM -- Server reboots

is this possible?
_________________
Toshiba Satellite A45-S121 - 2.8GHz Celeron @3.2GHz // 512MB RAM // OnBoard VGA // WLAN
==
Athlon XP 2000+ @ 2.2GHz // 768MB PC2700 @ 177FSB // eVGA 6600GT // 60GB Maxtor
Back to top
View user's profile Send private message
Teetante
Guru
Guru


Joined: 02 Mar 2004
Posts: 515
Location: Oldenburg/Germany

PostPosted: Tue Aug 29, 2006 1:12 am    Post subject: Reply with quote

You can do everything in a cronjob you could do in your own shell, so if you can send text messages to the server from the shell you can do it in a cronjob the same way.
_________________
ICQ #81510866 - http://the-gay-bar.com - MSN tante@emptiness.de
Occam's Razor:
-"Entia non sunt multiplicanda praeter necessitatem."-
Back to top
View user's profile Send private message
ps2cho
Apprentice
Apprentice


Joined: 27 Jun 2005
Posts: 196

PostPosted: Tue Aug 29, 2006 6:06 am    Post subject: Reply with quote

i tried to read those guides but its complicated...
I dont know which cron to use first of all. I dont want to get the wrong one. Which is the best one to suit my issue?
_________________
Toshiba Satellite A45-S121 - 2.8GHz Celeron @3.2GHz // 512MB RAM // OnBoard VGA // WLAN
==
Athlon XP 2000+ @ 2.2GHz // 768MB PC2700 @ 177FSB // eVGA 6600GT // 60GB Maxtor
Back to top
View user's profile Send private message
Teetante
Guru
Guru


Joined: 02 Mar 2004
Posts: 515
Location: Oldenburg/Germany

PostPosted: Tue Aug 29, 2006 11:59 am    Post subject: Reply with quote

It's not really important which one you use, I use dcron and have not had any problems with it.
_________________
ICQ #81510866 - http://the-gay-bar.com - MSN tante@emptiness.de
Occam's Razor:
-"Entia non sunt multiplicanda praeter necessitatem."-
Back to top
View user's profile Send private message
ps2cho
Apprentice
Apprentice


Joined: 27 Jun 2005
Posts: 196

PostPosted: Tue Aug 29, 2006 7:27 pm    Post subject: Reply with quote

Ok i emerged it and in the cron.daily folder i put basically what i have in my hlds_2.sh file into a hlds_2.cron file then chmod +x 'd it.

But how do i make it so it does it at a specific Time instead of 12:00(or whatever time it does it) daily ?
_________________
Toshiba Satellite A45-S121 - 2.8GHz Celeron @3.2GHz // 512MB RAM // OnBoard VGA // WLAN
==
Athlon XP 2000+ @ 2.2GHz // 768MB PC2700 @ 177FSB // eVGA 6600GT // 60GB Maxtor
Back to top
View user's profile Send private message
Teetante
Guru
Guru


Joined: 02 Mar 2004
Posts: 515
Location: Oldenburg/Germany

PostPosted: Tue Aug 29, 2006 7:33 pm    Post subject: Reply with quote

Look at /etc/crontab. Syntax is like this:
Code:

#m h dom mon dow user command
00  3   *       *    *    game_server  /usr/local/bin/script

Every Entry needs one value for (m)inute, (h)our, (dom) [day of month], (mon)th, (dow) [day of week], username and scriptname (more can be read with
Code:
man 5 crontab
.
The first example I gave executes /usr/local/bin/script as user "game_server" at 3:00 am. every day.
_________________
ICQ #81510866 - http://the-gay-bar.com - MSN tante@emptiness.de
Occam's Razor:
-"Entia non sunt multiplicanda praeter necessitatem."-
Back to top
View user's profile Send private message
ps2cho
Apprentice
Apprentice


Joined: 27 Jun 2005
Posts: 196

PostPosted: Wed Aug 30, 2006 5:22 am    Post subject: Reply with quote

EDIT: oh sorry i didnt read the last line that puts it all together :)

Ok i'll give it a try.

Should the /etc/crontab be empty ? just wondering...

...

Oh wait there isnt a file called crontab. ?
_________________
Toshiba Satellite A45-S121 - 2.8GHz Celeron @3.2GHz // 512MB RAM // OnBoard VGA // WLAN
==
Athlon XP 2000+ @ 2.2GHz // 768MB PC2700 @ 177FSB // eVGA 6600GT // 60GB Maxtor
Back to top
View user's profile Send private message
tlailax
Apprentice
Apprentice


Joined: 22 Feb 2004
Posts: 187

PostPosted: Thu Aug 31, 2006 7:43 am    Post subject: Reply with quote

my /etc/crontab sais that dcron (or fcron which i use) will not use /etc/cron.daily by default unless you include the contents of /etc/crontab in root's crontab.

and since when does the crontab format need a <user> element before the command ? fcron and vcron at least don't (fcron allowes for more flags, but before the minute element, not between the dow and command)

if you want the simplest cron i suggest vcron, and edit a single user's crontab using crontab -e ( run as the user owning the cron)

putting a job in /etc/cron.daily will make it run daily, but with the time specified in /etc/crontab. if you want to set a different time either modify that time, or better, edit the user specific crontab.
_________________
(\ /)
(O.o)
(> <)
This is Bunny. Copy Bunny into your signature to help him on his way to world domination
Back to top
View user's profile Send private message
tlailax
Apprentice
Apprentice


Joined: 22 Feb 2004
Posts: 187

PostPosted: Thu Aug 31, 2006 7:44 am    Post subject: Reply with quote

/etc/crontab should not be empty (it can be, but i've never seen the default file empty)
the default contains at least 5 cron jobs.
_________________
(\ /)
(O.o)
(> <)
This is Bunny. Copy Bunny into your signature to help him on his way to world domination
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum