Monthly Archives: April 2012

Why doesn’t my cron job run?

Possible reasons your cron job won’t execute:

  • Check your script
  • Type the exact content of your script in your terminal window and verify that is is working manually. Then, if your server supports it, check if it works when you execute manually from web interface.
  • Use full paths
  • Many servers will run scripts without full paths both from the command line and in the web interface; however, they may not run on schedule.
  • If you are using:
  • * * * * * cd /users/home/username/domains/mydomain.tld/web/public/folder; php -f cron.php > /dev/null 2>&1
  • Try this, with full paths:
  • * * * * *cd /users/home/username/domains/mydomain.tld/web/public/folder; /usr/local/bin/php -f cron.php > /dev/null 2>&1
  • The time is not set correctly
  • The time is usually GMT/UTC on your server. Don’t look at your system clock. Click here for instructions to see the date/time on your server. Also, verify that the correct minutes, hours, days, months, and weekdays are active.
  • Reference files have been moved or deleted
  • Check any files used in your script and make sure they are in the location referenced by your script.
  • Your cron job is not active
  • Make sure your cron job is marked active (not disabled)

Display date and time via unix command line

To display the date and time, enter the following in your terminal:
# date
Sample output:

[myserver:~] username$ date
Sunday, April 22, 2012  8:29:14 AM GMT

What version of Apache am I running?

Httpd is the Apache HyperText Transfer Protocol (HTTP) server program. To display the current apache version, type the following in your terminal window:
# httpd -v
Sample output:

Server version: Apache/2.2.3
Server built:   Oct 28 2008 07:22:45

Output list of modules compiled into the server:

# httpd -l
This will not list dynamically loaded modules included using the LoadModule directive. To dump a list of loaded Static and Shared Modules:
# httpd -M
Sample output:

Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_file_module (shared)
 authn_alias_module (shared)
 authn_anon_module (shared)
 authn_dbm_module (shared)
 authn_default_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 authz_owner_module (shared)
 authz_groupfile_module (shared)
 authz_dbm_module (shared)
 authz_default_module (shared)
 ldap_module (shared)
 authnz_ldap_module (shared)
 include_module (shared)
 log_config_module (shared)
 logio_module (shared)
 env_module (shared)
 ext_filter_module (shared)
 mime_magic_module (shared)
 expires_module (shared)
 deflate_module (shared)
 headers_module (shared)
 usertrack_module (shared)
 setenvif_module (shared)
 mime_module (shared)
 dav_module (shared)
 status_module (shared)
 autoindex_module (shared)
 info_module (shared)
 dav_fs_module (shared)
 vhost_alias_module (shared)
 negotiation_module (shared)
 dir_module (shared)
 actions_module (shared)
 speling_module (shared)
 userdir_module (shared)
 alias_module (shared)
 rewrite_module (shared)
 proxy_module (shared)
 proxy_balancer_module (shared)
 proxy_ftp_module (shared)
 proxy_http_module (shared)
 proxy_connect_module (shared)
 cache_module (shared)
 suexec_module (shared)
 disk_cache_module (shared)
 file_cache_module (shared)
 mem_cache_module (shared)
 cgi_module (shared)
 version_module (shared)
 chroot_module (shared)
 perl_module (shared)
 php5_module (shared)
 proxy_ajp_module (shared)
 python_module (shared)
Syntax OK

Print the version and build parameters of httpd, and then exit

Type the command:
# httpd -V
Sample output:

Server version: Apache/2.2.3
Server built:   Oct 28 2008 07:22:45
Server's Module Magic Number: 20051115:3
Server loaded:  APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

To view other configuration settings open httpd.conf file (usually located in /etc/httpd directory).Red hat, CentOS and Fedora stores httpd at the following location:
# vi /etc/httpd/conf/httpd.conf
Debian and Ubuntu stores httpd.conf in apache2.conf file at the following location:
# vi /etc/apache2/apache2.conf
FreeBSD stores apache2.2 configuration at the following location:
# vi /usr/local/etc/apache22/httpd.conf
If you made any changes to httpd.conf, check httpd syntax for error using the -t option:
# httpd -t

Rename folder cp via unix command line

To rename a file or folder, enter the following in your terminal:
# cp oldfilename newfilename
# cp oldfoldername/ newfoldername/

Using SSI (Server Side Includes) with domain aliases

I had several domain aliases and wanted to show a different html page based on the domain visited. Since these sites are all very similar, I wanted to share images and other content between them. I also wanted to be able to update the content in only one location. After some research, I determined that SSI could do exactly what I needed.

Add lines to your .htaccess file

Options +Includes
AddType text/html .shtml
AddHandler server-parsed .html .shtml
DirectoryIndex index.shtml index.html index.php

Enter the following in your index.html file

<!–#if expr='”$HTTP_HOST” = “domain1.tld” || “$HTTP_HOST” = “www.domain1.tld”‘–>
<!–#include virtual=”domain1.html” –>
<!–#elif expr='”$HTTP_HOST” = “domain2.tld” || “$HTTP_HOST” = “www.domain2.tld”‘–>
<!–#include virtual=”domain2.html” –>
<!–#elif expr='”$HTTP_HOST” = “domain3.tld” || “$HTTP_HOST” = “www.domain3.tld”‘–>
<!–#include virtual=”domain3.html” –>
<!–#elif expr='”$HTTP_HOST” = “domain4.tld” || “$HTTP_HOST” = “www.domain4.tld”‘–>
<!–#include virtual=”domain4.html” –>
<!–#include virtual=”NoneOfThese.html” –>

Explanation of above:

Options +Includes Turn on includes
AddType text/html .shtml Recognize .shtml file extension
AddHandler server-parsed .html .shtml Process both .html and .shtml for SSI
DirectoryIndex index.shtml index.html index.php Display index pages in this order

You can find many resources online that will explain all the features of SSI. Here, I am only looking to say “if the domain visited is or, then show X.html”.

Breakdown of SSI index.html

<!–# … –> Process for SSI
<!–#if expr=’ … ‘–> Start ‘If’ evaluation. If … is true, then execute next action
“$HTTP_HOST” String value for current domain name
“$HTTP_HOST” = “domain1.tld” Value of ‘True’ if current domain is domain1.tld
|| ‘Or’ operation. If either is true, then result is true
include virtual=”domain1.html” Insert content from domain1.html
<!–#elif expr=’ … ‘–> If nothing true yet, then continue checking elseif lines
<!–#else–> If noting was true, then execute next line
<!–#endif–> Stop processing this ‘If’ statement


DNS Servers

Here is a list of DNS servers that I commonly use:

Comcast (National Primary) (National Secondary) (Virginia) (Virginia) (Denver, Colorado) (Denver, Colorado) (Taylor, Michigan) (Taylor, Michigan) (Huntsville, Alabama) (Huntsville, Alabama) (Pennsylvania) (Pennsylvania)
Earthlink and Mindspring

Joyent (TextDrive) shared server addresses

Here are important addresses for TextDrive (VCII, VCIII, VCIV, Mixed Grill) and Joyent (Accelerator and Golden Ticket upgraded) shared hosting accounts.

Newer accounts (Joyent):


Usermin and Webmail





Older accounts (TextDrive):








Delete folder and contents with rm via unix command line

To delete a folder and it’s contents, enter the following in your terminal
# rm -dfr foldername
Analysis of the above command

-d remove folders
-f remove the files without prompting for confirmation or error messages
-r remove recursively, folder and its contents

More Examples

rm myfile.jpg Remove the file called myfile.jpg in the current directory.
rm *.jpg Remove all files that end with .jpg.

Zip only some files (jpg) via unix command line

To create a new zip archive ‘’ including only select files, you can use an expression argument after the command. Enter the following in your terminal to compress all jpg fies in current directory:
# zip *.jpg
If you want to only compress mp4 files with ‘720p’ in the filename, enter the following:
# zip *720p*.mp4

htaccess 301 (permanent) Redirect and RedirectMatch

There are many different types of redirects. Here are a few different permanent redirects. All of these can be added to your htaccess file. The directories listed are relative to the htaccess location.

Redirect visitors of a single page to a different page.

# Redirect permanent /directory/index.html http://subdomain.domain.tld/AnotherPage.html

Redirect visitors of any page within a directory to a specific page.

# RedirectMatch 301 ^/mydirectory/ http://subdomain.domain.tld/AnotherPage.html

Redirect visitors of any page within a directory to that page in a different location. Notice the missing slash here, compared to above.

# RedirectMatch 301 ^/mydirectory http://subdomain.domain.tld/AnotherPage.html

Redirect your entire website to any other domain or directory

# Redirect 301 / http://domain.tld/

301 (Permanent) Redirect: Point an entire site to a different URL on a permanent basis. This is the most common type of redirect and is useful in most situations. In this example, we are redirecting to the “” domain:

# This allows you to redirect your entire website to any other domain
Redirect 301 /

302 (Temporary) Redirect: Point an entire site to a different temporary URL. This is useful for SEO purposes when you have a temporary landing page and plan to switch back to your main landing page at a later date:

# This allows you to redirect your entire website to any other domain
Redirect 302 /

Redirect index.html to a specific subfolder:

# This allows you to redirect index.html to a specific subfolder
Redirect /index.html

Redirect an old file to a new file path:

# Redirect old file path to new file path
Redirect /olddirectory/oldfile.html

Redirect to a specific index page:

# Provide Specific Index Page (Set the default handler)
DirectoryIndex index.html