DevOps: Part II

On this second part, I’ll walk you through the basics of installing a VM with the Ubuntu 16.04 LTS as guest OS. Also, I’ll set up a programming environment with Python 2.7 and apache, installation of git and set up a cron task to do something every hour.

Installation of VM

For this task, I will use Parallels Desktop, this software allows users to install any OS you want as long as it is compatible. It allows the use of use of any Linux distribution, windows, and even Android for mobile. In this case, I chose Ubuntu Linux and it is downloaded right away. Installation is pretty straight forward and not complicated. Once it is installed, you’ll be prompted a password which is going to be your user password. Only downside to this is that your user is going to be called parallels, I haven’t figured out how to solve this from the beginning of the installation. It is important to tell you that some drivers need to be installed so that Parallels can be used at its full potential. Python 2.7 is installed by default, so there’s no need to install it again.

Installation of Apache2 Server

Apache is a common, but powerful web server. It is commonly used to host web sites and apps. Service is served on port 80 by default, which is also the default port for HTTP.
To install this, open up a terminal and type this:
sudo apt-get install apache2
After successful installation, open up a browser and go to localhost:80. And a page like this will show up on your browser.

Screen Shot 2019-03-10 at 7.44.48 PM.png
http://localhost:80

If you want to install more services such as PHP and MySQL follow the instructions on this page.

Installation of git

As later on, we will be doing cron tasks related to git repositories,  we need to install git version control. It is fairly simple to do so, just write the command below in your terminal and in a couple of minutes git should be ready.

apt-get install git-core

after that you can check that git is running by typing git --version to verify the installation.

Cron tasks

The cron tasks are a way to automate some tasks and schedule them as often as you want. To do so, I’m going to use the crontab service, this daemon can be used and installed on any UNIX system. For this sample cron task I will fetch this blog every hour of every day, of every month.

To start, open up a terminal and type crontab -e, this will open the editor of your choice, and will show up all active cron tasks (if it is the first time, you’ll see none). Cron syntax is as follows:

* * * * * command

So, the asterisks represent the frequency of the task. The first one is minutes, it sets how often in terms of minutes (0-59) the task will be done. The second one is hours, it sets how often in terms of hours (0-24) the task will be done. The third one is the day, it sets how often in terms of days of the month (1-31) the task will be done. The fourth one is the month, it sets how often in terms of  months (1-12) the task will be done. The last one one is the day of the week, it sets how often in terms of  days (0-6) the task will be done.

For example, a task to make a file called test.txt in the desktop folder every day will look like this:

0 0 * * * touch /Desktop/test.txt

This means that it’ll be done on the minute 0, at 12 o’clock. This second example means that the task will create a file called test.txt in the desktop folder every 15th of the month at 18:30.

30 18 15 * * touch /Desktop/test.txt

Now, for the last example, the task will pull all of this website every day at 13 o’clock.

0 13 * * * wget -r https://qualityandtesting.wordpress.com

Leave a comment