Linux CronJobs and Crontabs

3 replies [Last post]
AiKO . RS*
Offline
Joined: Nov 2005
Posts:

Hello@all
I mean to say, thats my server restart Automatish, i read in any forums that i can do per linux crontab, That problem i dont know how Thinking
I Test The Port Swich scribt by Faiht, its dosenet work on linux. ( in windows works excellent)
Can anybody me tell what i musst write in crontab.

Asus M2N - SLI Deluxe,AMD Athlon 64 X2 5000+,Radeon X1950 PRO 512 MB,1GB Hyper-X DDR2-800


+++DDL-Dream+++

RATSALAD
ratsalad's picture
Offline
Joined: Dec 2005
Posts:
Linux CronJobs and Crontabs

Well, first of all you have the file /etc/crontab, where cron jobs are set. There are seven fields to a cron job entry. lets assume you want to restart the server at 4am every morning.. you would have something like this:

0 4 * * * username_to_run_as killall q3ded && q3ded +set fs_game excessiveplus etc.. etc.. etc.. >> /dev/null 2>&1

Now, just so you have a bit better understanding of how it works, I'll go over the seven fields.

First field of the minute of the day you want to run it at. So like in my example, 0 would be the top of an hour. The second file is the hour of the day, so in the example that's the 4th hour.... so that's 4:00 in the morning. The third field is the day of the month ( acceptable values: 1-31.... duh Laughing ), the fourth is the month (values: 1-12). The fifth filed controls the day of the week the job is ran (accepted values are 0-6.. 0 being Sunday, 1 being Monday, etc.). The last two fields are obvious in the example but, for the sake of being complete and thorough... The sixth value is the user login name you want the command to be ran as. The seventh is the command or string of commands that get ran. Where you see asterisks (the *'s), that's basically telling crontab that field is omitted.

So... say I wanted to run a command, at 2:04am every Wednesday Laughing
4 2 * * 3 ratsalad command_here

There you go... the very basics of crontab.

One more thing to keep in mind. Any time you're editing a configuration file, always be sure that your entries don't wrap. You could use a simple command line editor such as nano, and turn word wrapping off, ie: nano -w /etc/crontab

AiKO . RS*
Offline
Joined: Nov 2005
Posts:
Linux CronJobs and Crontabs

Thank you Ratsalad!
I hope my crontab is working Happy
I has crate start scripts for server´s like chiller1v1.sh etc...
2nd question: do that work?
0 4 * * * q3 killall q3ded && sh chiller1v1.sh && sh chillertdm.sh && sh chillerfreeze.sh >/dev/null 2>&

Asus M2N - SLI Deluxe,AMD Athlon 64 X2 5000+,Radeon X1950 PRO 512 MB,1GB Hyper-X DDR2-800


+++DDL-Dream+++

RATSALAD
ratsalad's picture
Offline
Joined: Dec 2005
Posts:
Linux CronJobs and Crontabs

I believe that last part should be >> /dev/null 2>&1

What that does is disables e-mail's or messages in the spool telling you the action has been taken... it can be omitted if you don't care if it does or not Laughing