Saturday, September 27, 2008

using Crontab scheduler

Using The CRON Unix/Linux Program Scheduler

CRON is a Unix/Linux program scheduler. It'll automatically execute commands on your server according to a schedule you specify.

Almost anything that needs to be done according to a schedule and that doesn't need direct human supervision can be set up with Unix/Linux CRON.

To create a CRON schedule, put a list of commands and their schedules in a plain text file. This text file is called the "CRON table." Upload the CRON table to your server. Then telnet or SSH to your server.

Once at your server, type CRONtab filename replacing "filename" with the file name of the CRON table you uploaded to your server. This will register your CRON table with the CRON system.

If you want to verify that the CRON system has indeed registered your CRON table, type:

CRONtab -l

(the letter el, not the number 1). That will display a list of the current registered CRON schedules.

The CRON Table
The CRON table has six fields. The first five fields are schedule time fields and the sixth is the command itself:

1. The minute of the hour the command shall execute.

2. The hour the command shall execute.

3. The day of the month the command shall execute.

4. The month the command shall execute.

5. The day of the week the command shall execute.

6. The command.

All six fields are on one line. There is one space between each field. Only field 6 may contain spaces within itself. Here is an example of what a schedule might look like:

10 3 1 1 * /usr/bin/perl /www/cgi-bin/script.cgi

Comments in the CRON table, ignored by the server, are lines beginning with the # symbol.

The Five Schedule Time Fields
The order of the fields might seem backward. Most of us are used to thinking hour before minute, as in 9:45. Also month before day, as in June 21. However, the fields are minute before the hour and day before month, with the day of the week as the fifth field.

Here are the first five fields and their allowed values:


Field Values

----- -------

Minute 0-59

Hour 0-23

Day of the Month 1-31

Month 1-12 (also 3-letter month abbr)

Day of the Week 0-7 (also 3-letter day of week abbr)

Each of the above values can also contain ranges, lists, and step values. If a field contains an asterisk (*), it tells CRON to accept all allowed values.



Range 1-3

List 3,5,7

Step 15-45/5 (another example: */5)

For explanation, let's assume the above is in the Minute field.

Range 1-3 is a range of 1 through 3, inclusive, and means 1, 2, or 3 minutes after the hour.

List 3,5,7,9 means 3, 5, 7, or 9 minutes after the hour. Step 15-45/5 means every 5 minutes while the clock is 15 through 45 minutes after the hour, inclusive.

Step */5 means every five minutes while the clock is 0 through 59 minutes after the hour (* meaning all allowed values, which would be range 0-59 minutes).

Hypothetical Situations
For purposes of explaining each field, let's use three hypothetical situations.

1. A script must run one minute before the end of every year.

2. A script must run at 2:20 every Tuesday morning.

3. A script must run every 15 minutes from 9 in the morning to 9 in the evening. And it must run every 30 minutes the rest of the time. (Note, this requires two schedule lines.)

The Minute Field
The minute is the first field. The values examples of range, list, and step, above, illuminate the versatility built into the system.

For each of the three hypothetical situations, the minute field would be:

1. 59

2. 20

3a. */15

3b. */30

The Hour Field
The hour is the second field. The allowed values are the same as the minute field, 0-59.

For each of the three hypothetical situations, the hour field would be:

1. 23

2. 2

3a. 9-21

3b. 0-8,22-23

The Day Of the Month Field
The day of the month is the third field. The allowed values are 1 through 31.

For each of the three hypothetical situations, the day of month field would be:

1. 31

2. *

3a. *

3b. *

The Month Field
The month is the fourth field. The allowed values are 1 through 12. Instead of digits, 3-letter abbreviations may be used:

1 2 3 4 5 6 7 8 9 10 11 12

jan feb mar apr may jun jul aug sep oct nov dec

For each of the three hypothetical situations, the month field would be:

1. 12

2. *

3a. *

3b. *

The Day Of the Week Field
The day of the week is the fifth field. The allowed values are 0 through 7. Digits 1 through 6 represent Monday through Saturday, respectively. On some systems, 0 represents Sunday and on others 7 represents Sunday. On a few systems, both 0 and 7 represent Sunday. Your hosting company can tell you which applies to your server. Or, you may wish to try 0 and see if the script runs on Sunday. If it doesn't, try 7. Instead of digits, 3-letter abbreviations may be used:

0 1 2 3 4 5 6 7

sun mon tue wed thu fri sat sun

For each of the three hypothetical situations, the day of week field would be:

1. *

2. 2

3a. *

3b. *

The Hypothetical Situations Schedules
For each of the three hypothetical situations, the complete schedule (with an example sixth field) would be:

1. 59 23 31 12 * /usr/bin/perl /www/cgi-bin/script.cgi

2. 20 2 * * 2 /usr/bin/perl /www/cgi-bin/script.cgi

3a. */15 9-21 * * * /usr/bin/perl /www/cgi-bin/script.cgi

3b. */30 0-8,22-23 * * * /usr/bin/perl /www/cgi-bin/script.cgi

The Sixth Field, The Command
The sixth field is the actual command that will be executed according to the schedule specified in the first five fields. The sixth field includes any parameters to be passed to the command.

When the command is a Perl script, you might or might not need to specify the location of Perl as part of the command. Your hosting company can tell you which applies for your server.

Here are a three command examples:


/usr/bin/perl /www/cgi-bin/script.cgi

/usr/bin/perl /www/cgi-bin/script.cgi response.txt

The first example is a Perl script without the location of Perl being specified.

The second example is the same script, but this time the location of Perl is specified.

The third example includes a parameter. Here, the parameter is "response.txt," which might be the file name that an autoresponder is to send, assuming the autoresponder script is named script.cgi. When a script requires parameters, it's instructions should clearly indicate what the parameters are and what they represent.

On-line Documentation for CRON and CRONtab
You can type either or both of the following commands at the telnet or SSH prompt for the on-line CRON and CRONtab manuals. (It is assumed that any hosting company with CRON available also has the manuals on-line.)

man CRON

man CRONtab

Those two on-line manuals provide a lot of technical information.

A Practice Script
You can use the following script to practice what you have learned.

# Verify above line is correct for your server.

use strict;

my @date = localtime;


$date[5] += 1900;

$date[5] = substr($date[5],2);

open W,">track.txt";

print W "$date[2]\:$date[1]\:$date[0] on ";

print W "$date[4]\/$date[3]\/$date[5]\n";

# Above is USA style date. For European
# style, reverse digits 4 and 3. close W;
# end of practice script

The script will create a file named "track.txt" and print the time and date. Every time it runs, it creates a new file. The script is specifically made for running from the telnet/SSH prompt or with CRON, not for a browser. (Running this script in your browser will generate an internal server error. That's because the script never returns anything to the browser.)

When the script is uploaded, you can test it from the telnet/SSH prompt. To test, type the command you'll be using when you create the CRON schedule.

Once the script runs correctly, create the CRON schedule. You may wish to use */3 or something similar in the minute field while testing. As you now know, that will launch the script every three minutes; then the longest you'll wait between tests is three minutes.

Once the test is over, remove the test script from the CRON schedule. Launching a script, whether with CRON or through a browser, does take some server resources.

Saturday, September 6, 2008

Assignment MS-01 Question 02

Discuss the importance of communication for a manager. Describe various barriers to effective communication and how to overcome them to make communication more effective

Importance of communication for a manager:
Communication is one of the basic functions of management in any organization and its importance can hardly be overemphasized. It is a process of transmitting information, ideas, thoughts, opinions and plans between various parts of an organization.
You cannot have human relations without communication. However, good and effective communication is required not only for good human relations but also for good and successful business.
You can use softwares like business writing software for writing effective business communication, which is required at various levels and for various aspects in an organization such as -
Importance of communication for manager and employee relations:

Effective communication of information and decision is an essential component for management-employee relations. The manager cannot get the work done from employees unless they are communicated effectively of what he wants to be done? He should also be sure of some basic facts such as how to communicate and what results can be expected from that communication. Most of management problems arise because of lack of effective communication. Chances of misunderstanding and misrepresentation can be minimized with proper communication system.
For motivation and employee morale:

Communication is also a basic tool for motivation, which can improve morale of the employees in an organization. Inappropriate or faulty communication among employees or between manager and his subordinates is the major cause of conflict and low morale at work. Manager should clarify to employees about what is to be done, how well are they doing and what can be done for better performance to improve their motivation. He can prepare a written statement, clearly outlining the relationship between company objectives and personal objectives and integrating the interest of the two.
For increase productivity:

With effective communication, you can maintain a good human relation in the organization and by encouraging ideas or suggestions from employees or workers and implementing them whenever possible, you can also increase production at low cost.
For employees:

It is through the communication that employees submit their work reports, comments, grievances and suggestions to their seniors or management. Organization should have effective and speedy communication policy and procedures to avoid delays, misunderstandings, confusion or distortions of facts and to establish harmony among all the concerned people and departments.
Importance of written communication:

Communication may be made through oral or written. In oral communication, listeners can make out what speakers is trying to say, but in written communication, text matter in the message is a reflection of your thinking. So, written communication or message should be clear, purposeful and concise with correct words, to avoid any misinterpretation of your message. Written communications provides a permanent record for future use and it also gives an opportunity to employees to put up their comments or suggestions in writing.
Use of business writing software for effective business communication:

So, effective communication is very important for successful working of an organization. Writing software like business writing software with grammar checker and text enrichment tool can be used for writing effective business communications.

No matter how good the communication system in an organisation is, unfortunately barriers can and do often occur. This may be caused by a number of factors which can usually be summarised as being due to physical barriers, system design faults or additional barriers.
Physical barriers are often due to the nature of the environment.
Thus, for example, the natural barrier which exists, if staff are located in different buildings or on different sites. Likewise, poor or outdated equipment, particularly the failure of management to introduce new technology, may also cause problems. Staff shortages are another factor which frequently causes communication difficulties for an organisation.
Whilst distractions like background noise, poor lighting or an environment which is too hot or cold can all affect people's morale and concentration, which in turn interfere with effective communication.

System design faults refer to problems with the structures or systems in place in an organisation. Examples might include an organisational structure which is unclear and therefore makes it confusing to know who to communicate with.
Other examples could be inefficient or inappropriate information systems, a lack of supervision or training, and a lack of clarity in roles and responsibilities which can lead to staff being uncertain about what is expected of them.
Attitudinal barriers come about as a result of problems with staff in an organisation. These may be brought about, for example, by such factors as poor management, lack of consultation with employees, personality conflicts which can result in people delaying or refusing to communicate, the personal attitudes of individual employees which may be due to lack of motivation or dissatisfaction at work, brought about by insufficient training to enable them to carry out particular tasks, or just resistance to change due to entrenched attitudes and ideas.
Psychological factors such as people's state of mind. We all tend to feel happier and more receptive to information when the sun shines.
Equally, if someone has personal problems like worries about their health or marriage, then this will probably affect them.
Different languages and cultures represent a national barrier which is particularly important for organisations involved in overseas business.
Individual linguistic ability is also important. The use of difficult or inappropriate words in communication can prevent people from understanding the message.
Poorly explained or misunderstood messages can also result in confusion. We can all think of situations where we have listened to something explained which we just could not grasp.
Physiological barriers may result from individuals' personal discomfort, caused, for example, by ill health, poor eye sight or hearing difficulties.
Presentation of information is also important to aid understanding.

Assignment MS -01 Question 01

Describe different skills required for a manager and the responsibilities of a professional manager.

*Analyze, on a periodic basis, workload and personnel needs of an organizational unit.
*Recommend changes in the staff level of the work unit.
*Review documentation for new positions and positions that have been revised.
*Obtain approval to modify positions.
*Interview candidates for employment and make hiring decision or recommendations.
*Orient new subordinates concerning policy and procedures, work rules, and performance expectation
levels. Review position responsibilities.
*Plan, delegate, communicate and control work assignments and special projects concerning
*Establish and maintain specific work goals and objectives or quantitative and qualitative work standards
to be achieved by subordinates.
*Train, develop, and motivate subordinates to improve current performance and to prepare for higher level
*Determine significant changes in responsibilities and major duties of subordinates by reviewing their job
responsibilities on a regular basis.
*Evaluate the performance of subordinates. Document and discuss present and past
*performance with each direct report. Keep supervisor informed of results.
*Review salaries of subordinates and recommend changes according to policy and procedures.
*Recommend personnel actions such as promotions, performance awards, demotions, etc., according
to budget guidance and policy.
*Advise superiors and subordinates of developments that impact job duties. Ensure proper
*Maintain discipline, recommend and administer corrective action according to policy and procedures.
*Communicate and administer personnel programs in accordance with design and objectives.
*Maintain proper documentation on all subordinates.
*Direct the business activities of the company for the achievement of short and long term business/policy objectives, increased profit, production activity, or market share.
*Establish the business's objectives, policies and programmes within the context of the overall Corporate plan and, where appropriate, recommend standards and set targets (may include manufacturing, sales, marketing, distribution and administration).
*Prepare, or arrange for the preparation of the business's budgets, reports and forecasts, and ensure they are presented in a timely manner to the MANAGEMENT.
*Appraise the activities of the BUSINESS according to overall strategies and objectives, and monitor and evaluate branch and division performance, the efficiency of staff, procedures and production costs.
*Co ordinate subordinate staff to optimise the use of human and material resources to achieve goals. Consult with subordinate staff and review recommendations and reports.
*Oversee the development and implementation of all BUSINESS activities including production, distribution and sales, to protect the funds invested.

*Plan and review the BUSINESS operating costs particularly with regard to production, output, quality and quantity, cost, time available, labour requirements, planned production programmes and control activities, inventory levels, freight and advertising.

*Direct the preparation of marketing plans, key customer strategies and sales forecasts recommended by subordinate managers and ensure adequate support is provided in all branches/areas.

*Control use of production plant facilities by planning maintenance, designating operating hours and supply of parts and tools.

*Direct research into new and improved production methods and products, changes in selling policies, and other areas necessary to ensure the continued growth of the business.

*Select, or approve the selection and training of senior staff. Establish lines of control and delegate responsibilities to staff.

*Provide overall direction and management of the business, including personnel, technological resources and assets. Maintain necessary contact with major suppliers, customers, industry associations and government representatives to achieve the objectives of the business.

*Ensure all the business's activities comply with relevant Acts, legal demands and ethical standards.

The three main parts are:
achieving the task
managing the team or group
managing individuals

***Your responsibilities as a manager for achieving the TASK are:
identify aims and vision for the group, purpose, and direction - define the activity (the task)
identify resources, people, processes, systems and tools (inc. financials, communications, IT)
create the plan to achieve the task - deliverables, measures, timescales, strategy and tactics
establish responsibilities, objectives, accountabilities and measures, by agreement and delegation
set standards, quality, time and reporting parameters
control and maintain activities against parameters
monitor and maintain overall performance against plan
report on progress towards the group's aim
review, re-assess, adjust plan, methods and targets as necessary

***Your responsibilities as a manager for theGroup / team are:
establish, agree and communicate standards of performance and behaviour
establish style, culture, approach of the group - soft skill elements
monitor and maintain discipline, ethics, integrity and focus on objectives
anticipate and resolve group conflict, struggles or disagreements
assess and change as necessary the balance and composition of the group
develop team-working, cooperation, morale and team-spirit
develop the collective maturity and capability of the group - progressively increase group freedom and authority
encourage the team towards objectives and aims - motivate the group and provide a collective sense of purpose
identify, develop and agree team- and project-leadership roles within group
enable, facilitate and ensure effective internal and external group communications
identify and meet group training needs
give feedback to the group on overall progress; consult with, and seek feedback and input from the group

***Your responsibilities as a manager for each INDIVIDUAL are:
understand the team members as individuals - personality, skills, strengths, needs, aims and fears
assist and support individuals - plans, problems, challenges, highs and lows
identify and agree appropriate individual responsibilities and objectives
give recognition and praise to individuals - acknowledge effort and good work
where appropriate reward individuals with extra responsibility, advancement and status