Hosting Tips & Deals Linux Server Administration Tips PHP Tips & Tutorials

Cron jobs (Crontab jobs) tricks and tips on DreamHost

Crontab is a utility tool on Unix-like OS that enables you to make a program daemon scheduled to run at a specified interval. For example, to fetch news feed and import them into your own database every hour on the hour or to send pre-written newsletters at a given time everyday.

With DreamHost you can easily add Crontab jobs at their proprietary web panel, but there are 2 tricks.

With PHP, you can specify the version to run the script, PHP4 or PHP5. DreamHost has both popular php versions installed at different locations:

/*PHP4: */
/*PHP5: */

With any PHP script, you can always achieve the same results with lynx -dump command that accesses and loads the script as any other browsers would do, thus making the server run the script.

Also it’s required to add this line:

#!/usr/local/bin/php -q

at the top before <?php declaration if you are configuring crontab in command line mode rather than adding it from the web panel of DreamHost.

Hosting Tips & Deals Linux Server Administration Tips

Colorful Linux Bash Console by .alias and .bash_profile

At Dreamhost, we are all granted unlimited number of accounts for SSH access to the servers. The default console setting is a monochromatic one just like that in the old DOS style that it sores the eyes to look through the lines for something. Read their wiki the other day and found it’s possible to reconfigure the color scheme to ease of console operations.

.alias and .bash_profile are the 2 basic console configuration files located at your home directory, hidden by default, and you have to use ‘ls -a’ to get them in sight. Download them via FTP and add a line:

alias ls 'ls --color=auto'

at the end of the file .alias, and add a line:

alias lsl='ls --color'

to the end of .bash_profile. Upload and replace the old ones on your server with them. Now you are blessed with a colorful console with the command ‘lsl -o‘, just like the one I have:




ID as HTML named anchors

Well, recently I have come across quite some tricks that will help web developers to spin out better web pages and one of them is this: actually, you don’t have to use <a name=”xxx”>xxx</a> for named anchors, in the example of

<h2 id="cottage">
  <a name="cottage">grandpa's warm cottage</a>

you can merely rely on the ID of the h2 tag for the same purpose, that is,
<a href="#cottage">I spent the summer with my grandpa!</a>
can take visitors directly to
<h2 id="cottage">grandpa's warm cottage</h2>
By employing this tip, you are effectively making use of preexisting semantic markup, reducing code, and saving the trouble to introduce a meaningless <a> everywhere you need to plant an anchor. Good one, huh!


Proprietary HTML comment tag in Internet Explorer of both Windows and Mac

Rarely heard of it from any of the popular web design / development sites (blogs, forums, info portals and so forth), there’s actually a neglectable implementation of the tag <comment> in both Internet Explorer Windows and Internet Explorer Mac.

You are <comment>not</comment> browsing on Internet Explorer.

You are not browsing on Internet Explorer.

In IE, comment tags are treated the same way as any native HTML comments are, text in between the tags are effectively ignored. However in other browsers such as Firefox, the comment tag is rendered as a normal one.

No more than a spice to amuse though, because rarely any hacking situations require the differentiation of both IE from other browsers.

Programming Tips & Insights Web Design Tips and Insights

One SSI directive to save all programming muggle’s effort and time

SSI stands for Server Side Includes that is a default module in Apache web server. In essence, it provides a very simple mechanism to include one HTML file in another one, thus tremendously reducing redundant coding and increase the ease of later maintenance.

So, to get 80% out of SSI, the only directive you pretty much need is this:

<!--#include virtual="/parts/footer.html" -->

Make sure ‘include’ is immediately after ‘#’ without any blank spaces.

As the file name suggests, you are adding a common site footer. You can do this to all other pages on your site, making updating footer very easy because you only need to modify /parts/footer.html to get the changes done.

To get 80% our of SSI, you only need one directive, that is <!–#include virtual=" … " –>. It’s the essence I believe. And to get the rest 20%, you might also want to know about these handy ones (incomplete, just examples I think that will amuse you):

Get file size:

<!--#fsize virtual="/parts/ads.html"-->

Get last modified date:

<!--#flastmod virtual="index.html"-->

Get visitor IP address:

<!--#echo var="REMOTE_ADDR" -->

Get today’s date:

<!--#echo var="DATE_LOCAL" -->

Setting and getting a variable:

<!--#set var="name" value="Rich" -->
<!--#echo var="name" -->

You can even do some concatenation:

<!--#set var="firstname" value="Rich" -->
<!--#set var="lastname" value="Mond" -->
<!--#set var="name" value="${firstname} ${lastname}" -->

You get the idea. =) However, to get SSI to work on your server, you might need to add the following directives to httpd.conf (that is, if you are your own server administrator) or .htaccess (if you are on your own by shared hosting):

Options +Includes

For further reading, please refer to:

  1. Apache SSI Tutorial
  2. Kavoir SSI Framework
  3. wikipedia SSI
  4. HTML Code Tutorial, SSI help forum is a good place to go seeking for help. I’m there by the name of yangyang. =)