|
Advanced virtual server
Administration (1)
pg. 22
The following sections describe how to configure
your virtual server to perform custom operations. Because these operations are
somewhat complex, we recommend you read all available documentation carefully
before attempting to customize your virtual server.
Your virtual server Start-up Files
Occasionally, the physical machine that hosts your virtual server must be
rebooted while we perform routine maintenance or software upgrades. Although
this usually results in little or no downtime, it can disrupt stand-alone
programs on your virtual server that don't restart automatically.
As a solution, you can create a start-up file called 'rc' in your ~/etc
directory. This text file can contain a list of commands, one per line, that you
would like to be executed in the event of a server reboot.
Commands that are entered into your ~/etc/rc text file will be executed whenever
your physical machine is restarted and will run exactly as if you had typed them
into your SSH session yourself.
Changing Your virtual servers Time Zone
This section explains how to change the time zone on your virtual server.
First, find the appropriate time zone in your virtual server’s
/usr/share/zoneinfo directory. To get there, SSH to your virtual server and type
the following from your home directory:
cd ../../share/zoneinfo Enter
The zoneinfo directory contains a subdirectory of regions. To view the list,
type:
ls Enter
The following list of regions appears:
AfricaEET Greenwich MST7MDTSystemV
America EST HST Mexico Turkey
AntarcticaEST5EDT HongkongNZ UCT
ArcticEgypt Iceland NZ-CHATUS
AsiaEireIndianNavajo UTC
AtlanticEtc IranPRCUniversal
Australia EuropeIsraelPST8PDTW-SU
BrazilFactory Jamaica PacificWET
CET GBJapan Poland Zulu
CST6CDT GMT Kwajalein Portugal posix
CanadaGMT+0 Libya ROCposixrules
Chile GMT-0 MET ROKright
CubaGMT0MST Singapore
Select a region (for example, US or Europe), and
move into that directory using the cd command.
Example: If you are choosing a US time zone, you would type the following:
cd US Enter
Now, find the time zone you wish to choose:
ls Enter
Another list appears for specific time zones within the region you choose.
Example: The following list of US time zones appears within the US directory:
Alaska Central HawaiiMountain
Aleutian East-IndianaIndiana-StarkePacific
ArizonaEastern MichiganSamoa
After you find the appropriate time zone, type
the following at the command prompt:
chmod 600 ~/etc/localtime Enter
Now, copy the file path of the time zone file into your ~/etc/localtime
directory.
Example: If you chose the US/Pacific time zone, you would type the following:
cp /usr/share/zoneinfo/posix/US/Pacific ~/etc/localtime
Enter
Your virtual server’s time zone information is now updated.
Automating Tasks with Cron
You may find it useful to run certain programs automatically on a regular basis.
For example, you may wish to have an email message sent to you each morning that
tells you how many visitors your Web site had on the previous day, or how many
people downloaded files from your anonymous FTP service. The cron facility is
available to you for such purposes. Cron allows you to automate such tasks so
that they run at whatever time and frequency you desire.
To use cron, you first need to create a standard text file containing
information about which programs you want to run, and when you want to run them.
Such a file is called a cronfile. You then need to load the contents of this
file into the cron table of your virtual server using the crontab command. Cron
can seem a bit cryptic at first, but once you are familiar with the format of a
cron entry, it’s easy to understand.
A standard cron entry in your cronfile text file might look like this:
55 23 * * * ls
The first part of a cron entry tells when the command should be executed. It
consists of 5 parts. From left to right it shows the minute (0-59), hour (0-23),
day of month (1-31), month (1-12), and day of week (0-6 or Sun-Sat). The second
part tells cron the command to execute. In this example, cron is being told to
run the ls command (which will simply display a directory listing) at 11:55pm
every day of every month. The asterisk (*) is used as a wild card, to show that
the command should be valid for every instance of this measure of time (second,
hour, day, month, etc.).
You can also pipe the results of a command run by cron to another command or
file. For example, to mail the output of a command executed by cron, you could
pipe the command’s output to the mail command, and provide the necessary command
line arguments to send the mail where you want it to go. In this case, you could
mail the directory listing to webmaster@yourdomain.com by altering the cron
entry to read:
55 23 * * * ls | virtual sendmail webmaster@yourdomain.com
While mailing a directory listing to yourself may not be very useful, it does
demonstrate the abilities of the cron facility.
Following are some more useful examples of cron. You can experiment with the
times and/or commands that are run by cron to achieve the desired results on
your virtual server.
More information on cron is available by typing the following at your virtual
server’s command prompt:
man cron Enter
Loading the Cronfile
Use the pico editor to make entries to your cronfile. The cronfile can be called
anything, but for simplicity, you could simply call it “cronfile.” To load the
contents of a cronfile into the cron table so that they will become active cron
entries, type the following:
crontab cronfile Enter
The cronfile should be the name of the text file that contains your cron
entries. The crontab command must be run from the directory where your cronfile
is located. If you wish to view the active cron entries for your virtual server,
you can do so at any time by typing:
crontab –l Enter
Virtual Server Lite |
Virtual Server Standard |
Virtual Server Pro |
Virtual Server Ultra |
400 megs |
1000 megs |
1500 megs |
6000 megs |
Details |
Details |
Details |
Details |
Order |
Order |
Order |
Order |
|