Archive

Archive for December, 2007

Setting Server System Date Time

December 23rd, 2007 Behzad 1 comment

To see current server/system date and time at login as root:

# date

To see current server/system date and time in UTC:

# date -u

Now if you want to adjust system time read below.

Setting Server System Time

Open http://www.time.gov in browser and choose a TimeZone.

Run the date command to set date and time with following format:
(Note! this is only the format, you must change date and time value before running this command)

# date -s ’12/23/2007 13:36:30′

And if you want to set date and time according to UTC, open http://www.time.gov/timezone.cgi?UTC/s/0/java then run:

# date -u -s ’12/23/2007 13:36:30′

Now you can fix your hardware clock with system time:

# /sbin/hwclock -r
Shows your system hardware clock time.

# /sbin/hwclock –adjust
Makes changes the hardware clock to follows system time.

# /sbin/hwclock –systohc
Sets the hardware clock to the system time.

Now most likely you have more accurate system time.

Linux Kill or Stop Processes

December 21st, 2007 Behzad No comments

To see processes do:

# ps auxf

To find a specific process:

# ps auxf | grep [process-name]

To stop a process without killing it:

# kill -STOP [pid]
SIGSTOP (17,19,23) stops a process without killing it

To restart a stopped process:

# kill -CONT [pid]
SIGCONT (19,18,25) restarts a stopped process

To force killing a process:

# kill -9 [pid]
SIGKILL (9) forces the process to terminate immediately and performs no cleanup

# killall [process-name]
SIGKILL (15) kill all the processes of specific application
kill and killall both send a SIGTERM (15) by default. SIGTERM (15) can be caught and either ignored, or interpreted in a different way, so when it works unpredictably, you can blame the process you’re trying to kill.

Killing a parent process will usually, but not always, kill its children as well.

Automate Virtuozzo backups on Windows

December 20th, 2007 Behzad No comments

There is currently no GUI option to automate Virtuozzo backups, although not in current version 3.5.1 SP1.
This will be possible in Virtuozzo 4.0, which is currently in beta.

I’m using 2 bat files to script the backups and remove the oldest backup.
The first script creates a full backup of all virtual private servers using the vzbackup command:

for /F “skip=3 usebackq tokens=*” %%i in (`cmd /c “vzlist -ao veid”`) do (cmd /c “vzbackup “%%i && echo VE ID %%i has been backed up!)

To be able execute the second script you need to download RmEmpty, an executable which allows you to remove empty directories, get it here

First, we’ll have to search the destination folder on the backup node for files older then x days, in this example I use 4 days.
forfiles /P e:\vz\backups /S -D -4 /c “cmd /c del /q @file”

The forfiles is a default windows binary, some information about the given variables:
/P indicates the path to start searching
/S instructs forfiles to recurse into subdirectories
/D selects files with a last modified data less than or equal to (-)
/C indicates the command to execute for each file
The /q is to delete the files quietly, otherwise it will ask for a confirmation before deletion.

After deleting the files we’ll search for empty directories, and remove them:
C:\system\rmemp12\RMEMPTY.EXE e:\vz\backups\

Be aware that if e:\vz\backups\ itself is also empty, it will remove that one too! So always keep at least 1 file in that directory, I use a simple readme.txt so it never gets deleted.

How do I automate backup operations in Virtuozzo?

December 20th, 2007 Behzad No comments

VE backups can be created using vzbackup utility. It should be run on the backup node. You can restore any backup using vzrestore utility.
To configure vzbackup you should do the following:

  1. Check global vzbackup configuration file /etc/vzbackup.conf file on the backup node for backup parameters (pay attention to $BACKUP_DIR parameter).If you are going to make backups using cronjob, set the following parameters:
    # Backup directory – where the backups will be stored, e.g

    BACKUP_DIR=”/vz/backups”

    # backup type. Supported types are “full”, “initial incremental” and
    # “incremental”. Default is incremental. If it is impossible to do
    # “incremental” then “initial incremental” will be done.

    BACKUP_TYPE=”i”

    # Backup cron mode

    CRON_BACKUP=”yes”

    # List of nodes to backup.

    BACKUP_NODES=”"

    # e-mails to send notifications on backup

    BACKUP_NOTIFY_EMAIL=”root@myserver.com”

  2. Create directory

    # mkdir /vz/backups

  3. Add the following command to the crontab on the backup node:

    # vzbackup -i -p -a

  4. Make sure root user of the backup node is able to access all hardware nodes without a password (propagate DSA public keys)

Keywords: backup,vzbackup,restore,vzrestore

cPanel Image::Magick Perl module installation failure

December 20th, 2007 Behzad No comments

It’s better to install from source as the versions are constantly changing and the dependencies too.

First remove any old RPM installations

# rpm -qa | grep -i Magick

# rpm -e anything that pops up.

Go to your favourite install directory (/usr/src) whatever

# wget ftp://ftp.imagemagick.org/pub/ImageM…eMagick.tar.gz

# tar xvzf ImageMagick.tar.gz

cd into the new folder (current version is ImageMagick-6.3.3)

# cd ImageMagick*

Configure it with whatever crazy stuff the customer needs:

# ./configure –with-x=no

OR

# ./configure –enable-shared –with-modules –without-x –with-gs-font-dir=default \
–with-perl=yes –with-xml=yes –with-zlib=yes –with-jpeg=yes ;

(And any other mindless stuff you feel like throwing in

# make && make install

From the folder you are in:

# cd PerlMagick

# perl Makefile.PL

# make

# make install

And you’re all done.

Credits to Stephanie_R at cPanel forums.

If you have problems after installtion please read http://behzad.nategh.com/movable-type-and-imagemagick/

BUT HOLD ON, this is not it yet!

We need to get it locked into PHP !

The new WHM has a fantastic utility to complete the task.

Log into WHM >> Software >> Module Installers >> PHP Pecl and install imagick to get the whole thing binding into PHP and making your applications gell ! :)