Posts Tagged Linux
Generate Crontab (Cron jobs) syntax/command using this simple tool
Posted by admin in Linux, Open Source on December 26th, 2010
Cron is a daemon used for scheduling tasks to be executed at a certain time. You can easily find great articles on Crontab or Cron daemon on the Internet. I found these articles very useful and easy to understand.
1. https://help.ubuntu.com/community/CronHowto
2. http://en.wikipedia.org/wiki/Cron
Actually, here I don’t want to explain how crontab work and how you can schedule tasks using crontab. I just want to discuss this tool I’ve created for generating crontab entries/syntax which you can copy and directly put in your crontab file.
In this tool there are five sections; minute, hour, day, month and weekday. You can select single or multiple values for each section from the list which you want to use in your crontab file.
You may want to run a script some number of times per time section. For example if you want to run crontab job in every 10 minutes (runs on minutes divisible by 10: 0, 10, 20, 30, etc.). In this case you can use “Every (x) minute” option and select 10 from drop down list. You can also get the correct output from “Minutes(s)” list but this option will generate less cumbersome output.
In “Command” text box you need to enter full command you want to execute in crontab. When you click Submit you will see this command with values for different section.
There should be single space between each section with the final section (command) can having one or more spaces in it.
Create Virtual Hosts and run multiple websites on Amazon server
You can create virtual hosts on any Linux or window platform if you are using Apache web server. Virtual hosts or v-hosts is basically Apache feature. I’m considering here Amazon server running with Apache version 2 or above. So, basically for creating v-hosts you need to modify Apache’s configuration (httpd.conf) file. You need the root access for all this modifications. Here I’m showing how we create the “name-based virtual hosting“. This is the easiest way of creating virtual host.
On Amazon server httpd.conf is located on ‘/etc/httpd/conf/httpd.conf‘ location. You need to follow these steps:-
1. First, take the backup of this file so in case if anything goes wrong you can rollback changes.
2. Download this file in your local machine and open it in any text editor.
3. Go to section 3 (Virtual Hosts) of this document.
### Section 3: Virtual Hosts
4. Un-comment this line
NameVirtualHost *:80
5. Now create v-hosts like this
<VirtualHost *:80> ServerAdmin admin@mydomain1.com DocumentRoot /var/www/html/domainname1 ServerName www.domainname1.com ErrorLog logs/www.domainname1.com-error_log CustomLog logs/www.domainname1.com-access_log common </VirtualHost> <VirtualHost *:80> ServerAdmin admin@mydomain2.com DocumentRoot /var/www/html/domainname2 ServerName www.domainname2.com ErrorLog logs/www.domainname2.com-error_log CustomLog logs/www.domainname2.com-access_log common </VirtualHost>
Here we have create two virtual host one www.domainname1.com and second one www.domainname2.com. We have specified 5 Apache directive into a VirtualHost container. We can put almost any Apache directive into a VirtualHost container. Let’s discuss each one by one.
ServerAdmin – Here we specified email address of server administrator. If there is any issue Apache show this email address for contact.
DocumentRoot – Here we give the absolute path of directory where our website files are located.
ServerName – Here we give the name of our domain which is pointed to “/var/www/html/domainname1″ directory.
ErrorLog – Absolute path of Error log file for this domain.
CustomLog – Absolute path of custom log file for this domain.
6. Restart the Apache web server to apply these changes.
You can restart your Apache server using Terminal or Putty on Windows.
service httpd restart
Note:- One more thing which you need to do is you need to point both the domains “www.domainname1.com” and “www.domainname2.com” to the IP address of the Amazon server.
The Apache server it self find out the domain name form request header and point the incoming request to correct “DocumentRoot” directory.
