Archive for the 'Linux Support' Category

SBDavid

tee command

tee command

Print the results to the screen but also to a file.

ps -e | grep apache | tee apache-processes.txt

You can enter more than one filename if you want multiple copies.

SBDavid

Cron

Cron is a time-based job scheduler in Unix-like computer operating systems.

cron - daemon to execute scheduled commands (Vixie Cron)

Example: the following will clear the Apache error log at one minute past midnight each day.

1 0 * * * echo “” > /www/apache/logs/error_log

There is also an operator which some extended versions of cron support, the slash (’/') operator (called “step”), which can be used to skip a given number of values. For example, “*/3″ in the hour time field is equivalent to “0,3,6,9,12,15,18,21″.

So “*” specifies ‘every hour’ but the “*/3″ means only those hours divisible by 3.

# .—————- minute (0 - 59)
# | .————- hour (0 - 23)
# | | .———- day of month (1 - 31)
# | | | .——- month (1 - 12) OR jan,feb,mar,apr …
# | | | | .—- day of week (0 - 6) (Sunday=0 or 7) OR sun,-to-,sat
# | | | | |
# * * * * * command to be executed

How can I see the environment variables a process is running with?

You can run the following command:

ps auxwwe |grep processname

How to forward a website to another url using PHP

To do this, you need to create the page that will do the forwarding. This can be any page, as long as it ends in “.php”. If you are trying to redirect a domain, you’d create “index.php” inside the public_html directory.

<?php
header(”Location: http://blog.serverbuddies.com”);
?>

Where http://blog.serverbuddies.com is the location that you want the page to forward to.

SBDavid

Using Perl to Change TTL Values

Using Perl to Change TTL Values

We’ll change the TTL from 14400 to 100 seconds for all domains

perl -pi -e ’s/14400/100/’ named.db

When changing the IP of a domain, end users will have the old IP of the domain cached at their ISP’s nameservers for a duration of the TTL (time to live). The default value is 14400 seconds (4 hours). This means, that when you change the IP of the sever, the worst case, is the end users will be using the wrong IP for 4 hours before the cache expires and the IP is recached with the correct value.

The simple way to minimize this propogation error is to lower the TTL.

« Prev - Next »