Affichage des articles dont le libellé est Basic. Afficher tous les articles
Affichage des articles dont le libellé est Basic. Afficher tous les articles

samedi 12 novembre 2016

How to save time with cron: Basic guide and sample codes



alt="How to save time with cron: Basic guide and sample codes" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2015/04/default-image-500x308_c.jpg" />

What is cron?

Cron is a Linux/UNIX daemon that is designed to execute a command at a predefined time. Since cron is a daemon, once it is executed it does not require any administration from the user. Cron is controlled by a set of files called “cronfiles”, below is a list of common cron commands.

class="border" width="100%" cellspacing="0" cellpadding="1">bgcolor="#DDDDDD" width="200"> Crontab filename bgcolor="#DDDDDD">Install filename as your crontab file.valign="top" width="200">crontab -evalign="top">Edit your crontab file.valign="top" width="200">crontab -lvalign="top">Show your crontab file.valign="top" width="200">crontab -rvalign="top">Remove your crontab file.valign="top" width="200">MAILTO=user@domain.comvalign="top">Emails the output to the specified address.

Each entry into the crontab file will consist of the following six fields separated by a space. The order of the fields along with a brief description of each one is listed below.
minute(s) hour(s) day(s) month(s) weekday(s) command(s)

class="border" width="100%" cellspacing="0" cellpadding="1">bgcolor="#dddddd" width="100"> Fieldbgcolor="#dddddd" width="100">Valuebgcolor="#dddddd">Descriptionvalign="top" width="100">Minutevalign="top" width="100">0-59valign="top">Defines the exact minute the command will execute.valign="top" width="100">Hourvalign="top" width="100">0-23valign="top">Defines the hour of the day the command will execute.valign="top" width="100">Dayvalign="top" width="100">1-31valign="top">Defines the day of the month the command will execute.valign="top" width="100">Monthvalign="top" width="100">1-12valign="top">Defines the month of the year the command will execute.valign="top" width="100">Weekdayvalign="top" width="100">0-6valign="top">Defines the day of the week the command will execute.
Sunday=0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6valign="top" width="100">Commandvalign="top" width="100">Specialvalign="top">The complete command that will be executed.

You can also use an * in place of the numerical character of the first five fields to indicate all legal values. For example, 0 0 * * 1 command, would run a script on every Monday.
Most of this section is only relevant if you are running scripts from the command terminal in Linux/UNIX, if you are using a cPanel please view the “How do I run a cron script from my cPanel” section.

How can I save time with cron?

There are many ways you can use cron to save some but to me the most useful tasks you can schedule are running database and website backup scripts. Both of these jobs can easily be done manually but they are often over looked. With cron you can set them up once and know it will get done.

Below are sample scripts you can use to setup these jobs with cron.

Automatic WordPress Database Backups (Script provided by href="http://tamba2.org.uk/wordpress/cron/" target="_blank">T2)

#Set the 4 variables
#Replace what is AFTER the = with the information from your wp-config.php file

DBNAME=DB_NAME

DBPASS=DB_PASSWORD

DBUSER=DB_USER

#Keep the ” around your address
EMAIL=”you@your_email.com”

mysqldump –opt -u $DBUSER -p$DBPASS $DBNAME > backup.sql
gzip backup.sql
DATE=`date +%Y%m%d` ; mv backup.sql.gz $DBNAME-backup-$DATE.sql.gz
echo ‘Blog Name:Your mySQL Backup is attached’ | mutt -a $DBNAME-backup-$DATE.sql.gz $EMAIL -s “MySQL Backup”
rm $DBNAME-backup-$DATE.sql.gz

Automated Website Backups (Script provided by href="https://help.ubuntu.com/8.04/serverguide/C/backup-shellscripts.html" target="_blank">Ubuntu)

#!/bin/sh

####################################

#

# Backup to NFS mount script.

#

####################################

# What to backup.

backup_files=”/home /var/spool/mail /etc /root /boot /opt”

# Where to backup to.

dest=”/mnt/backup”

# Create archive filename.

day=$(date +%A)

hostname=$(hostname -s)

archive_file=”$hostname-$day.tgz”

# Print start status message.

echo “Backing up $backup_files to $dest/$archive_file”

date

echo

# Backup the files using tar.

tar czf $dest/$archive_file $backup_files

# Print end status message.

echo

echo “Backup finished”

date

# Long listing of files in $dest to check file sizes.

ls -lh $dest

 

*Disclaimer: We are not a responsible if the script fails to run correctly or if you set it up incorrectly. If you have any questions or concerns about the script or how to set it up the best contact will be your host provider.

How do I run a cron script from my cPanel?

1. Log into you cPanlel

2. Locate the “cron jobs” icon (This is generally in the advanced section).

class="border" src="http://www.webhostingsecretrevealed.com/images/2011/1116-1.jpg" alt="" />

3. Enter your E-Mail address if you would like a copy of the crop output to be emailed to you.

class="border" src="http://www.webhostingsecretrevealed.com/images/2011/1116-2.jpg" alt="" />

4. Choose when you would like your cron script to run. (Choosing an item from the “Common Settings” dropdown box will fill in the fields for you.)

class="border" src="http://www.webhostingsecretrevealed.com/images/2011/1116-3.jpg" alt="" />

5. Enter the path of the script you would like to run. (Note: You will need to upload your script file to your server, for more information please see below – “How do I upload my script file” section for details.)

class="border" src="http://www.webhostingsecretrevealed.com/images/2011/1116-4.jpg" alt="" />

6. Click “Add New Cron Job”

class="border" src="http://www.webhostingsecretrevealed.com/images/2011/1116-5.jpg" alt="" />

7. Your cron job should now be listed under “Current Cron Jobs”.

class="border" src="http://www.webhostingsecretrevealed.com/images/2011/1116-6.jpg" alt="" />

How do I upload my script file?

class="border" src="http://www.webhostingsecretrevealed.com/images/2011/1116-7.jpg" alt="" />

  1. From your cPanel choose “File Manager”
  2. Next choose “Home Directory” then click “Go”
  3. Now choose “Upload”.
  4. Set your File Permissions to 755
  5. Click “Browse”
  6. Browse to the folder that has your script and click on it, and then click “Open”.

Note: Your cPanel may be setup differently than the one shown above but the overall concepts should still be the same.


Page 26 – Web Hosting Secret Revealed




The Basic of Memcached Hosting



alt="The Basic of Memcached Hosting" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2015/04/default-image-500x308_c.jpg" />

What is Memcached Hosting?

class="aligncenter" src="http://www.webhostingsecretrevealed.com/images/2011/0208-2.jpg" alt="Memcached Hosting" width="565" height="104" />

In a world full of and dependent on technology, few could deny that it is always changing, and at a dizzying pace. When it comes to the internet, the demand for portability, quicker connection speeds, and flexible costs has lead to various plans for both limited and unlimited hosting. The purpose for these plans are simple; the delivery of content and the processing of applications are improved, a fact that cannot be overlooked.

With each passing day, open source communities and premium service providers edge increasingly closer to the other, to the point that the gap is almost non-existent. With this benefit comes strengthened server resources, and this new trend is recognized as a member of the long list of internet modifications.

Developed by the company Danga Interactive, Memcache was first used on a website that goes by the name of Live Journal. Soon after this was released, it gained use on other websites due to the fact that the source code was considered a hot commodity. Among more well-known sites that use it regularly, Craigslist, Twitter and YouTube are included.

Open source design has a lot of impressive contributions under its belt; memcache and its attachment to open source code only proves this to be true. Incomplex in nature, it has gained a following of enthusiasts who would consider it one of their favorites. Made of key-value in-memory, it stores data from page rendering, API calls, and database calls. At the end of this series of actions, dynamic applications will experience increased speed.

The Very Definition of Caching

id="floatright">class="alignright" src="http://www.webhostingsecretrevealed.com/images/2011/0208-3.jpg" alt="Memcached" width="200" height="373" />

It may be confusing, but with better understanding of caching it is easier to appreciate. At the base of the matter, a cache involves the duplication of data, making it unnecessary to have the original data in order to view something. In other words, it is a special storage area that holds frequently used data temporarily.

If it is still unclear, another way to explain caching is through the use of web data. For many people who frequent the internet, it is standard to have a favorite website that they visit frequently and may even have bookmarked. Whenever they visit these places, if the data of the pages was not saved, it would take a lot longer for everything to load properly. A cache’s job is to store some of the data on the hard drive of the computer so that everything will load quicker. There is no need for the browser to spend extra time going through the database located at the server.

Memcache makes everything run in a more efficient manner. It is sensible in design, helps where it is needed, and is popular as a result. To illustrate, the basic architecture of a memcache-host stack would commonly comprise of the OS, the server layer, the cache layer, the database and  the page script layer. When the data is stored in the memory caching layer, the database of the website receives minimal hits during the attempt to get the information. When a great number of interactive sites house a database that holds their information, this is even more so important.

The Many Functionalities of Memcached As A Service

Beyond the obvious benefit of server load optimization, having memcache in your host opens up a wider range of capabilities for your dynamic website. The following functionalities can be achieved with memcache support:

1. Communication Management – Better spam control, and distributed locking service.

2. Online-member tracking – Member activity transparency and easier maintenance of expired-member purges.

3. Scalable web services – Unrestricted use of resource intensive features such as CRON.

4. Versioning System – More server backup

5. Summarize Db update demographics – Increased accuracy of update analysis

Memcached as a Service is far from perfect though because of its inherent weakness in security, but for high-traffic dynamically generated websites memcached hosting ultimately is a great option to consider.


Page 28 – Web Hosting Secret Revealed




Basic Guide On Dedicated Hosting



alt="Basic Guide On Dedicated Hosting" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/dedicated-hosting-500x216_c.jpg" />

Readers that want complete control of their web hosting environment often decide to purchase a dedicated server for their web hosting needs. As my last written href="http://www.webhostingsecretrevealed.com/web-hosting-knowledge/dedicated-hosting-a-to-z/">guide on dedicated server hosting was in 2009; I believe it is time for me to revisit the facts and get a fresh copy done on the topic.

Introduction: The Basics Of Dedicated Hosting

class="border" alt="Dedicated Web Hosting Deals" src="http://www.webhostingsecretrevealed.net/images/2012/0618-1.jpg" width="750" />

Unlike shared servers in which one computer is shared among several clients, a dedicated server provides a customer with their own computer that is managed by the href="http://www.webhostingsecretrevealed.net/choose-the-right-web-hosting/">web hosting company. The web hosting company takes on the responsibility of ensuring that the equipment runs properly and takes care of any hardware related issues. Typically, customers are expected to have the knowledge to manage their own software installations and troubleshoot any software related issues that arise. Since other users are not hosted on the same computing environment, a dedicated server usually provides additional security when configured properly. This is extremely important for a business that needs to protect valuable information.

While dedicated servers provide additional flexibility, privacy and the ability to run any application or operating system, this freedom comes with additional responsibility. Many companies choose to lease a dedicated server to house different aspects of a companies business. For instance, one server may be used solely for email, another for databases and a third for actual website content. The actual hardware for the server is stored in a data center that gives the hosting company easy access to monitor the health of the hardware and swap any parts as needed. While the hosting company takes care of any hardware related issues, it is generally acknowledged that the customer must take care of all but the initial installations and software optimizations.

Most customers opt to install a control panel to make it easier to administer the dedicated server. The most commonly used administration tools are CPanel and WHM. CPanel makes it possible to upload files to a Linux based system, create backups, install software applications and monitor hardware usage. WHM is the container for CPanel and makes it possible to protect the server against hackers, viruses, rootkits and other security risks.

Security: Protecting Visitors and Content

id="floatright">class="alignright" alt="" src="http://www.webhostingsecretrevealed.net/images/2008/0520-1.jpg" width="350" height="233" />

Administrators for dedicated servers are tasked with several responsibilities. They must set up and manage the software firewall, test for rootkits and install the necessary software, and understand what programs cause security vulnerabilities within the server environment. Administers must also be knowledgeable in how to detect brute force attacks and other malicious attacks used by hackers. Additionally, an administer should know how to mask the operating system and other identifying information that might be used by a hacker to find weaknesses in the security of the website.

Securing the website is crucial to protect sensitive visitor information and prevent the website from getting blacklisted in search engine results. Websites that are known to distribute malware, even if it is through no fault of their own are often penalized and in some cases completely removed from search results. For a website that relies upon search engine results to find content, this penalty is extreme and can destroy an otherwise successful business.

Managed or Unmanaged Servers: When to Hire Help

Luckily, there is help for the webmaster that knows how to design and program an effective website but doesn’t know how to manage or ensure that software installations are up-to-date. For users that need the flexibility and freedom to run a wider range of applications but don’t have the skills necessary to protect the website, many hosting providers offer managed severs. A managed server is professionally setup and maintained to ensure that the website remains safe and protected from threats. If something does threaten the server, skilled technicians can combat and protect the server from harm.

Unmanaged servers leave all of the daily cron jobs and scheduled tasks to the customer to set up and regulate. Little help is provided when things go wrong. Although, many hosting companies will help a new customer setup the initial account, if something goes awry, they are expected to have the knowledge to correct issues on their own. The customer is often responsible for several aspects of managing a server, including updating the operating system, applying patches and ensuring that the security of the system is up-to-date and complete.

Managed servers operate much more like a shared server in regards to security and software updates. On a shared server, the client never has to worry about installing updates for the operating system, applying patches, plugging security holes and monitoring traffic. The same is true for a managed server. Web hosting companies generally provide managed servers for an additional fee. The convenience of relegating the management of the server to the hosting company makes this an ideal solution for website designers and owners that have little experience with managing a server.

Hardware Options: Determining Required Resources

When purchasing a dedicated server it is essential to know precisely how much memory, hard disk space, bandwidth and CPU power is needed. Also, users must know what type of operating system works best for their needs. For a website that just has simple text and image based content, then it won’t be necessary to have large computing resources. For customers that are running large content management systems such as Joomla or educational systems such as Moodle, it is crucial to take into account available RAM, CPU and disk space requirements. When an application exceeds the allowable resources, the server may crash and need a manual reboot to continue serving pages to visitors.

Operating System

The operating system determines what applications can run on the computer. Consider the difference between an Apple and Windows computer. Both systems can run software, but the software has to be specific to the operating system. For instance, an application written for a Linux computer can’t run on a Windows computer. Knowing ahead of time what type of operating system will be run ensures that installed applications will run as expected. Most servers run a version of Linux or Windows on the server.

Memory

The amount of memory in a system partially determines how many tasks can be run at the same time and the speed at which they are run. Systems with low amounts of RAM will take longer to process information. This could result in a loss of sales on an eCommerce site or lost visitors on a site with several applications. Memory is also referred to as RAM. Basically, it is just a method of storing information that is needed immediately. Many system processes and other functions that require quick access are stored in RAM.

Disk Space

Disk space is crucial to ensure that the website can serve images, video, text and applications. When a system runs out of disk space, online backups are no longer possible and additional uploads to the server fail. Some software installations require more disk space than others. It is important to get the disk space usage right before starting on a dedicated server. When more disk space is needed, the entire contents of the hard drive often have to be transferred to a new computer. This can potentially create downtime and a loss of business if it isn’t performed correctly and with careful timing.

Data Transfer

Data transfer, or more commonly, bandwidth usage deals with how much information is served per month. Hosting companies have to charge for bandwidth since computer hard drives eventually fail. Bandwidth usage is determined based on the costs of replacing a hard drive and the expected life of the hard drive. Increasing the bandwidth for a busy site can generally be accomplished within 24 hours. Some hosting companies even allow the possibility for immediate changes to bandwidth requirements through an online ordering system.

CPU

The CPU determines the processing power of the server. Dual-core and Multi-core CPUs provide better performance and balance the workload over more than one processor. The processing speed determines the speed at which the pages are served and how long it takes to run a particular process or application. Backups take longer on a system with a slow processing speed. In fact, just about anything the computer does is affected by the processing speed of the computer. For website owners that need fast and reliable service, they should spring for the most expensive processor they can afford. The difference in speed will be immediately noticeable by website users.

Backups

One of the most important tasks for a website owner is the regular backup of the server. Don’t rely on the online backup tool to preserve a backup for future use. Most website owners should back up the entire server once per week. This can be completed through a control panel such as CPanel or by downloading all of the databases and files associated with the account on a weekly basis. Leaving the backup online won’t do any good if the entire hard drive fails. The safest solution is to download the backup and store it on a separate hard drive that is dedicated to backups. This ensures that if something does go wrong with the website a recent backup is available. Additionally, it makes sense to perform a full backup of everything on the website before making any major systems changes, operating system or software updates.

Quick Comparison Guide On Dedicated Hosting Deals

Before we end this article, let’s take a quick look on href="http://www.webhostingsecretrevealed.net/hosting-review/hostgator/">Hostgator, href="http://www.webhostingsecretrevealed.net/hosting-review/inmotion-hosting/">InMotion Hosting, and href="http://www.webhostingsecretrevealed.net/hosting-review/coolhandle/">CoolHandle dedicated hosting deals for comparison purposes.

class="border" width="100%" cellspacing="2" cellpadding="2">bgcolor="#dddddd">Server Featuresalign="center" bgcolor="#dddddd" width="145">Hostgatoralign="center" bgcolor="#dddddd" width="145">CoolHandlealign="center" bgcolor="#dddddd" width="145">InMotionCPUalign="center" width="145">Xeon 3360 /
Quad Corealign="center" width="145">3.0 GHz /
Core2 Duoalign="center" width="145">E2220 /
Dual CoreRAM Memoryalign="center" width="145">2 GBalign="center" width="145">2 GBalign="center" width="145">2 GBStoragealign="center" width="145">2 x 250 GBalign="center" width="145">2 x 160 GBalign="center" width="145">2 x 160 GBBandwidthalign="center" width="145">10 TBalign="center" width="145">2 TBalign="center" width="145">2.5 TBSSH Accessalign="center" width="145">Yesalign="center" width="145">Yesalign="center" width="145">YesDedicated IP Add.align="center" width="145">5align="center" width="145">1align="center" width="145">5Controal Panelalign="center" width="145">cPanel/WHMalign="center" width="145">cPanel/WHMalign="center" width="145">CentOSPricingalign="center" width="145">9.00/moalign="center" width="145">.95/moalign="center" width="145">9.95/mo

 

There are, of course, plenty of dedicated hosting providers around the globe but for easy reference, I picked the three I’m most familiar with so you can have a quick glance on the general. For further research, I suggest reading my href="http://www.webhostingsecretrevealed.net/hosting-reviews/">hosting reviews. Also, I would like to point out that the price and features of different dedicated hosting deals often vary greatly. This is because dedicated hosting plans, unlike shared hosting, are generally non-standard hosting plans; thus hosting companies are able to price their dedicated deals freely based on their man-power, expertise, as well as business margin. And, this is why, as a smart shopper like you, will need to do more homework and compare more different dedicated hosting deals when searching for one.


Page 23 – Web Hosting Secret Revealed




Mastering the Cron Job and Automating Basic Server Tasks



alt="Mastering the Cron Job and Automating Basic Server Tasks" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2015/04/default-image-500x308_c.jpg" />

Web hosting is designed to be easy, straightforward, and perfect for the professional who’s on the go and simply cannot dedicate every hour of every day to managing their server software and associated tasks. To that end, almost every server based on Unix or Linux offers an automated task manager known as the "href="http://www.wisegeek.com/what-is-a-cron-job.htm" target="_blank">Cron Job" or "Crontab." This software utility is much like the task scheduler in Microsoft Windows, in that it can be told to do certain things at certain times, saving a user from performing these tasks manually. This is especially important when one considers that many routine server maintenance, backup, and communications procedures can take hours and hours to complete. Most people simply want to go home after a day in the office and relax, rather than spend their evening backing up files and managing contacts.

Those people are in luck, as every task can be scheduled on a daily, weekly, or monthly basis — or even further apart, in some cases, and specific instructions can be given to the server within the Crontab utility on how to perform the task, how to know when it’s complete, and what to do when the task at hand has actually been finished. Users will be able to relax while their server does all of the heavy lifting for hours; or they can simply schedule the work to be completed while they’re hard at work in their own offices. Because it’s automated, a Cron job can occur at virtually any hour of the day.

Learning to Tell Time Using a Cron Job’s Format

src="http://www.webhostingsecretrevealed.com/images/2012/0412-1.jpg" class="border" />

A Cron job isn’t exactly an easy thing to master; in fact, it’s widely considered one of the most advanced configurations available on a standard href="http://gizbuzz.co.uk/2006/linux-explained/">Linux or href="http://staff.washington.edu/corey/unix-intro+man.html">Unix web server. This is partially because the language used to program these jobs is so archaic and, in some cases, completely backwards. When it comes to telling a certain time to the Cron job or Cron tab in question, things are certainly backwards, upside down, and a little confusing.

The format for telling time via a Cron job is such:

MINUTE HOUR DAY-OF-MONTH MONTH DAY-OF-WEEK COMMAND

It’s all one line, and even number and command is side-by-side in one uniform contraction. It’s enough to make most developers and server operators wince and, in fact, many of them do until they get a hang for developing an efficient Cron job. It’s important to note that every aspect of the Cron job’s time is numerical; there are no month names day names, or other words used throughout the development of the time during which a task should be performed.

Therefore, let’s set a Cron job up for 10:30 a.m. on July 7th in order to get a feel for how a Cron job’s time looks when it’s turned into strictly numbers.

30 10 07 07 *

The example above states that the job should be completed at the 30th minute of the tenth hour on the seventh day of the seventh month. All numbers are two digits long, even when the month or day is only a single digit. This is important to remember, as a single digit will often cause the Cron job to be invalid and it simply will not be performed, ever. At the end of the con structure, an asterisk indicates that the job should be performed on any day of the week. This is important, as setting it to 03 for Wednesday would mean that the task would only be performed on July 7th if that day was a Tuesday. That’s likely to happen once every seven or eight years, which is a little absorb for most developers to consider.

Another important consideration to make when setting up a Cron job is that the hour format is 24-hour military time rather than 12-hour civilian time. To change the time of Cron job to 10 p.m., the hour would be changed to 22 instead of the current 10.

src="http://www.webhostingsecretrevealed.com/images/2012/0412-2.jpg" alt="Cron Job Examples" class="border" />

Finally, if a user merely wants to complete a task on a daily, monthly, or even yearly basis, they can skip the process of setting a specific time entirely. Instead, the Cron job process provides for simply using variables which determine when a job is done on these frequent intervals. These include:

  • @daily
  • @monthly
  • @yearly

Because the time cannot be strictly controlled and determined using hours and minutes, these jobs will happen at exactly midnight, according to the server’s internal time, at the interval requested. That means that the @monthly interval will occur at exactly midnight on the first day of every month. The @yearly interval will occur at exactly midnight on the first day of every year; and the @daily interval will occur at exactly midnight every single day of the year.

This is far easier than setting a specific date, time, and day of the week, but certain tasks being performed at midnight on the first day of the month or year may have some drawbacks for certain customers. Always keep the needs of both administrators and site visitors in mind when scheduling tasks that occur at exactly midnight.

Grasping the "COMMAND" Variable and What to Do with It

As can be seen in the example above, constructing an actual Cron job is relatively easy. The date must be first defined and then the function of the Cron job is immediately defined afterward. That function can be literally anything, including running a PHP script or running a customized backup script that stores the server’s files and data in either a remote or local file. For clarification, we’ll build on the example that was previously used and instruct the Cron job to run a PHP script on July 7th at 10:30 in the morning. This PHP script will be called "backup.php" and we’ll assume that the PHP file is a full backup script that gathers, compresses, and stores site files on the seventh of the month when instructed to do so by the server. Here is what it looks like:

30 10 07 07 * http://your-domain-name.com/backup-scripts/backup.php

When this Cron job is entered into the list of the server’s Cron tabs, it will be automatically executed at 10:30 a.m. every July 7th of every year. It will run the PHP backup script that is located in the "backup-scripts" directory, and that’s where the true genius of the Cron job setup works.

Instead of requiring advanced commands of its users to perform things like site backups and cache flushes, it simply gives users the ability to execute existing scripts at a specified interval or on a specific date at a specific time. This means no advanced programming knowledge is needed beyond what the user already knows. PHP is perfectly capable of backup site files, as are much more advanced files and programming languages that the more sophisticated user might develop for their Linux server.

This simple setup can be used to do virtually anything, then, so long as a pre-written script provides for the execution of those actions independent of user input. This does mean that any script executed by a Cron job within a Cron tab must be fully automated and able to perform on its own, however. For example, it would be impossible (and simply illogical) to tell the Cron job to execute a WordPress index or theme file every day at the same time. There are simply no actions or automated processes defined and, while the Cron job would certainly execute the file, it would do nothing and would sit static until user input was provided in another way.

For this reason, if coding or downloading backup scripts or others to work with Cron jobs, always make sure that they require exactly zero user input to perform their functions successfully. An automated task scheduler must be paired with an automated process within the file it executes. There are no exceptions to this rule.

Mastering the Overall Cron Tab File on a Typical Server

Every specific Cron job which is specified for execution lies within a larger file which is known as a Cron tab. Some servers have multiple Cron tabs for multiple types of applications and automated inputs, but this is rare and largely reserved for the most advance server operators and owners. Those who have just one Cron tab file can use the commands below to edit, delete, or view the file in its entirety, with each of their specific automated tasks listed for viewing within the file.

crontab -r

This command removes (thus "r") or deletes the entire Cron tab file itself. This will effectively purge it of all commands and automated scripts, and restore it to a blank file that can be rebuilt. This is a suitable option for those who have managed to corrupt the file or somehow misappropriate tasks and times. Sometimes, it’s simply easier to start all over.

crontab -e

In this case, "e" stands for "edit." Those users who want to edit the functions described in a Cron tab rather than delete the file entirely can use this command to be taken to the command-line editor which will allow them to add new tasks, remove old ones, or change the applicable schedule times for each of the Cron jobs listed within the Cron tab document.

crontab -l

In this case, it’s easy enough to remember by associating the "L" with "look. This command allows a server administrator to simply view the full contents of their Cron tab file without removing it from the server entirely and without having the ability to edit the contents. This read-only display of Cron tab content is perfect for remembering which tasks are scheduled for which times, and for verifying the integrity of the file itself.

Why it’s Important to Master the Cron Job an Cron Tab Automation Files

id='floatright'>src="http://www.webhostingsecretrevealed.com/images/2012/0412-3.jpg" alt="Cron Job Examples" />

Generally speaking, the only thing automated about a server is the spinning of its hard disk and the performance of its hardware features. Beyond that, though, the server must the trained and instructed to do routine and extraordinary tasks that go above and beyond merely displaying a software control panel or upgrading the installation of PHP or Perl that a user has placed on the hard disk.

It’s important to remember that one of the most essential functions a server can execute on a regular basis is the creation of a site backup of data and settings. There is virtually no way to automate this process without a Cron job and, due to the nature of the internet and all of the malicious visitors which pass through a site daily, failure to automate this process on a daily or weekly basis could result in significant and catastrophic data loss.

Above and beyond that, though, there are a number of tasks that should be automated using the Cron job process. These tasks include purging any site caches which might display outdated images or printed content to site visitors; it also includes deleting old files, cleaning up old directories and images, and making sure that everything stored on a server’s hard disk drive is current and uncorrupted.

Just like a healthy personal computer automatically schedules disk maintenance, antivirus and malware scans, software updates, and file deletions, a healthy server must be configured to take care of itself and remain in good standing. Otherwise, it becomes vulnerable to crashes, hacking attempts, and data loss that will lead to lost profits, advertising, content creation, and even search engine ranking status.

Easy to Learn and Easier to Deploy

Creating a Cron job within a standard Cron tab is one of the easiest things a server administrator can do. The process lies within the standard command line and breaks down every segment of time into a two-digit code. Because it requires no additional knowledge of any new programming language in order to automate tasks, the service essentially builds on the existing programming and server operations knowledge that an administrator already possesses. With this being the case, there is simply no reason not to begin automating essential server functions and ensuring the integrity of site data and operations.

For further reference and more code samples, do check out Robert’s previous post: href="http://www.webhostingsecretrevealed.com/web-hosting-knowledge/how-to-save-time-with-cron-basic-guide-and-sample-codes/">How to save time with cron: Basic guide and sample codes as well as visiting this site: href="http://livecronjobs.com/" target="_blank">Live Cron Jobs.


Page 24 – Web Hosting Secret Revealed




Basic HTML for Bloggers



alt="Basic HTML for Bloggers" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/04/html-codes-500x266_c.jpg" />

style="line-height: 1.5em;">Ten years ago, you had to know some web coding to protect yourself, but now there are so many editors and plugins available that even knowing the basics of HTML is no longer required to href="http://www.webhostingsecretrevealed.net/blogging-with-whsr/">run a blog.

class="border aligncenter wp-image-9449 size-full" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/04/html-codes.jpg" alt="html codes" width="750" height="400" srcset="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/04/html-codes.jpg 750w, http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/04/html-codes-300x160.jpg 300w" sizes="(max-width: 750px) 100vw, 750px" />

The problem with this is that if you don’t know a few basics, you can easily get into real trouble in your blog and have to hire a pricey developer to fix what may be a minor problem. Not only that, but creating  changes to your blog such as adding a custom text widget requires a little knowledge. And if you are experiencing content layout doesn’t look right, HTML knowledge can get you back on track.

Here are some very basic HTML pointers for bloggers.

Word of Warning Before Writing HTML

style="line-height: 1.5em;">I want you to get comfortable using these tags, but you should always remember that if you leave out a portion of the tag, you can cause serious problems.

style="line-height: 1.5em;">Each tag has an end and a beginning, and leaving one of those out tells the computer that the tag is still open…and all the following code will be included in that tag. In addition, please type it out. If you copy and paste what I’ve written, you may get problems when the site interprets your code.

Links: The <a> tag

style="line-height: 1.5em;">One of the most important things to know is how to make links. The latest update of WordPress  is experiencing some issues with some “no follow” plugins, so while you are waiting for a compliant plugin, you’ll need to know how to set up a nofollow link for your sponsored and product review posts.

style="line-height: 1.5em;">The tag looks like this:

<a href="http://www.websiteyouarelinking.com/" target="_blank" rel="nofollow">Website Name</a>

style="line-height: 1.5em;">In the “a” is the tag, “href” tells the browser where to take the visitor once she clicks the link. The target “_blank” tells the browser to open that link in a new tab – very important so that visitors don’t leave your website completely. Next, we have the all-important “nofollow” link that you need to ensure you don’t get penalized by Google for compensated posts. (If you are writing a post that is not compensated, you can leave out ‘rel=”nofollow”’ to give the link a boost on Google.) Next comes the title – make it accurate and SEO-friendly. Finally, “</a>” closes this tag.

style="line-height: 1.5em;">Images: The <img> Tag

style="line-height: 1.5em;">Sometimes you’ll want to create text widgets that includs images or linked images. This is the code:

style="line-height: 1.5em;">Pulling in a single image:

<img alt="Gluten Free Brownies" src="http://mom-blog.com/wp-content/uploads/2014/04/2014016_brownies.jpg" width="490" height="293" />

style="line-height: 1.5em;">Notice that this is a SINGLE tag, but it ends with “ />” to close the  tag. In this tag, you’ll see “alt” tag. This is what you fill out after you load your image and is necessary for visitors who are visually impaired. (Make sure you use it to denote what the photo is, and not what you want your SEO to be.) “Src” is the link to where your image is actually located. “Width” and “height” are just that – the size of your image in pixels. This is optional, and should match your actual image size, or else the image will appear warped.

style="line-height: 1.5em;">Here’s how to set up an image with a link:

<a href="http://www.websiteyouarelinking.com/" target="_blank" rel="nofollow"><img alt="Gluten Free Brownies" src="http://mom-blog.com/wp-content/uploads/2014/04/2014016_brownies.jpg" width="490" height="293" /></a>

style="line-height: 1.5em;">As you can see, you simply replace the text from our <a> tag example (“Website Name”) with an image link and viola!

style="line-height: 1.5em;">The Paragraph Tag: <p></p>

 

id="attachment_9421" style="width: 310px" class="wp-caption alignright">class="size-full wp-image-9421" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/04/20140418-TextWidget1.jpg" alt="Text Widget on Page" width="300" height="266" />class="wp-caption-text">All created with a text widget and basic HTML

style="line-height: 1.5em;">Obviously, this tag puts your text or image in it’s own paragraph with spacing above the opening <p> and after the closing </p>.

style="line-height: 1.5em;">Usually, your theme’s blog or will have it styled so that there is a certain amount of space above or below it. You can easily adjust that by with a bit of style right in the tag.

style="line-height: 1.5em;">This is how it’s done:

<p style="width:200px; padding-right:5px; text-align:center;">Welcome to my blog!</p>

style="line-height: 1.5em;">That style tag allows all kinds of sizes and options, but here are these basic ones.

  • “Width” is the actual width of that paragraph. This had created a 200 pixel width paragraph. Make sure you width is NOT bigger than your column or  just leave width out to spread  text to the size of the column.
  • “Padding” literally puts space around your paragraph. You can add 5 pixels of space just to the right, for example, like it’s done here, if you feel your paragraph is too close to the edge on the right side. You can do the same for padding-left, padding-top and padding-bottom. You also have the options of “padding:5px” to put 5 pixels around each and every side.
  • “Text-align” justifies your text within the paragraph. Options are center, left, right and justify which spreads the text out to be even on both sides.

style="line-height: 1.5em;">Finally, you can use a paragraph with images and links as well but make sure your images’ width fits in your column too. Note that padding is added to that width:

<p style="padding-right:5px; text-align:center;"><a href="http://www.websiteyouarelinking.com/" target="_blank" rel="nofollow"><img alt="Gluten Free Brownies" src="http://mom-blog.com/wp-content/uploads/2014/04/2014016_brownies.jpg" width="490" height="293" /></a><p>

style="line-height: 1.5em;">The Link Break Tag: <br />

style="line-height: 1.5em;">This tag  gives you a one line return without a paragraph. It can be used inside a paragraph if you want a series of lines where you single line breaks that you select yourself (so that you can even out the lines) and still have a paragraph around it, like so:

<p style="width:200px; padding-right:5px; text-align:center;">Welcome to my blog!<br />Come in and make yourself at home.</p>

style="line-height: 1.5em;">Styles

style="line-height: 1.5em;">Now that I’ve already showed you some styles, I’m going to quickly list a few more that are useful for creating those text widgets:

  • BOLD: Place bolded text inside these tags: <strong>Text goes here</strong>
  • ITALICS: Place italicized text inside these tags: <em>Text goes here</em>
  • BOLD+ITALICS: Place text inside:<strong><em>Text goes here</em></strong>

style="line-height: 1.5em;">Heading Tags

id="attachment_9420" style="width: 310px" class="wp-caption alignright">class="size-full wp-image-9420" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/04/20140418-TextWidgetCode.jpg" alt="Text Widget Code" width="300" height="375" srcset="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/04/20140418-TextWidgetCode.jpg 300w, http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2014/04/20140418-TextWidgetCode-240x300.jpg 240w" sizes="(max-width: 300px) 100vw, 300px" />class="wp-caption-text">What text wdget code looks like

style="line-height: 1.5em;">For SEO purposes, you may want to use critical tags with your site’s main keywords in text widgets (on your sidebar, footer, etc.) These are heading tags and Google gives more weight to them. For example, your blog’s theme will usually have titles and site name within these tags. 

style="line-height: 1.5em;">These tags are:

  • <h1>Text goes here</h1>
  • <h2>Text goes here</h2>
  • <h3>Text goes here</h3>
  • <h4>Text goes here</h4>
  • <h5>Text goes here</h5>
  • <h6>Text goes here</h6>

style="line-height: 1.5em;">hese tags are in size order, with <h1> being the largest. Google gives the most weight to text in <h1>, next weight to <h2> and so on.

style="line-height: 1.5em;">Often, <h1> tags are quite large and may have a color. To eliminate that, you can enter something this:

<h1 style=”color: #000; font-size: 12px; font-weight:normal;”>Your new title here.</h1>

style="line-height: 1.5em;">That will give you black text (color: #000;) in a 12 pixel font (font-size: 12px;) and remove bold (font-weight:normal;). If this does not work, your site may have been coded in a more complex manner and you may simply want to select a smaller heading tag.

style="line-height: 1.5em;">Bullets

style="line-height: 1.5em;">Bulleted or numbered lists are a great way to show content to your audience. But you might find “weird” or inconsistent spacing when you edit them. This is what they should  look like in your text editor:

<ul>
  <li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>

style="line-height: 1.5em;"><ul> means “unordered list” – this will give you bullets. (If you want to use a numbered list, simply change all the “ul” tags to “ol.”) <li> means list item. There are times you’ll hit a return and it will create another <ul> within your list or close your list and start a new  one in the middle. It should look like some variation of the above, so if you see extra “<ul>” opening and closing tags, you can delete them.

Try Writing Your Own

style="line-height: 1.5em;">This will help you get started, but please make sure that you back up your site fully first (including theme) so you can restore. If you get into trouble with a widget, you can just remove it to figure out where you wrote the wrong code. Finally, feel free to type as normal in your visual editor and compare what you see in the text editor to get a feel for these basics.


Page 14 – Web Hosting Secret Revealed