Presentation is loading. Please wait.

Presentation is loading. Please wait.

ITI-481: Unix Administration Meeting 5 Christopher Uriarte Rutgers University Center for Applied Computing Technologies.

Similar presentations


Presentation on theme: "ITI-481: Unix Administration Meeting 5 Christopher Uriarte Rutgers University Center for Applied Computing Technologies."— Presentation transcript:

1 ITI-481: Unix Administration Meeting 5 Christopher Uriarte Rutgers University Center for Applied Computing Technologies

2 Today’s Agenda Job Scheduling - The Cron Program Syslogd and Logging Sendmail and UNIX mail concepts

3 The Cron Program UNIX’s answer to automated job scheduling. Used to schedule jobs to run at particular time or at a particular frequency. Useful to to automate system administration tasks. Powered by a background system process called crond (the cron daemon) is started at boot time from rc scripts.

4 Cron Files Configuration files defining scheduled jobs are generally stored in the directory: /var/spool/cron The main Cron directory, where jobs defined according to username. These definition files are called crontab files.

5 Cron Files, con’t. Each user on the system can have a corresponding crontab file specifying their own automated job schedule – including root. The simple text files are kept under the /var/spool/cron directory, named after each user, e.g.: –/var/spool/cron/root –/var/spool/cron/chris –/var/spool/cron/mary –etc.

6 Crontab File Format Crontab files use the following format, placing one job entry on each line: Minute Hour Day Month DayOfWeek Command Time fields are as follows: –Minute (0-59) –Hour (0-23) –Day of Month (1-31) –Month (1-12 or names jan-dec –Day of Week (0-6 or names mon-fri) –Command: A command, script or program name to run at the time specified Fields that are not specified for a particular entry are substituted with “*” Ranges can be specified by placing a “-” between elements, such as “mon-fri”

7 Crontab File Formatting Rules Fields that are not specified for a particular entry are substituted with “*” –As you definitions for more fields, the execution time generally becomes more specific. Ranges of dates or times can be specified by placing a “-” between elements, such as “mon-fri” or “1-5” Multiple dates or times for a field can be specified by specified using a comma between values, such as “mon,wed,fri”, which will execute a job on Monday, Wednesday and Friday.

8 Sample Cron Entries Sample entries: #Ping our mail file server’s IP address every 15 min 0,15,30,45**** /sbin/ping –5 192.168.15.7 | /bin/mail root #Mail a disk usage report every Friday at 5:00PM 0 17 * * fri df |/bin/mail root Remember the format!: Minute Hour Day Month DayOfWeek Command

9 Editing Crontab files Although crontab files are simple text files, they cannot be edited by opening them directly with a text editor like vi,emacs,pico, etc. You must use the crontab program to edit a user’s crontab file: To use the crontab: > crontab –u username –e Crontab will open the specified crontab file in the default system editor (usually vi). You can have it use your favorite text editor by setting the EDITOR environment varialble (I.e. EDITOR=pico)

10 Editing Crontab files, con’t. When you have completed editing your crontab file, exit your text editor as your normally would. Be sure to save the file you’ve just created (the crontab program will give the file a default name and location) If you do not format your cron entry correctly, the cron program will notify you when you attempt to exit your editor. You will then have the chance to fix the entry or exit your editor (which leaves the crontab file unmodified)

11 /etc/crontab Defines a set of directories that will run scripts or links located in those directories at specified times. Predefined cron directories: /etc/cron.hourly /etc/cron.daily /etc/cron.weekly /etc/cron.monthly Non-standard way of using cron.

12 Exercise: Creating Crontab Entries Edit the root crontab file: > cd /var/spool/cron > crontab –u root -e Create a crontab entry to run out of the root account to email a disk usage report to your internet.rutgers.edu account or another email address of your choice every 15 minutes of the hour. Check /var/log/cron to verify that your job ran.

13 Syslogd Most system logging is handled through the syslogd. Configuration file is /etc/sylog.conf. Log entries are directed to various files in /var/log. Messages logged by syslogd include a time stamp, the process or facility that delivered the message, and the message itself. Rotating log files periodically is recommended.

14 /etc/syslog.conf Format of syslog rule: facility.priorityaction –facility - system or application generating the message. –priority – level of severity of the message. –Wild cards are accepted. Sample entries: authpriv.* /var/log/secure mail.err/var/log/maillog Tab delineated file. If changes are made need to restart syslog daemon: > kill –HUP `cat /var/run/syslog.pid`

15 Additional Log Files /var/run/utmp – information about who is currently logged into system. Used by commands such as who and finger. /var/log/wtmp – login times and duration for each user on the system. Can view with last command. /var/log/lastlog – similar to wtmp but used by different programs, such as finger.

16 Electronic Mail System Components Mail User Agent (MUA) –Provides interface for reading mail, writing new messages, and filing. Also called a mailer. –Examples: mail, Pine, Netscape Mail, Outlook. Mail Transport Agent(MTA) –Routes mail from one user to another either locally or across systems. –Uses a transport protocol, usually SMTP (Simple Mail Transport Protocol), to provide the medium for mail transfer. –Examples: Sendmail, Qmail. Mail Delivery Agent (MDA) –Takes a message once received at a site and gets it to the appropriate user mailbox. –Examples: procmail, mail.

17 Workstation POP ServerSMTP Server Mail Spool SMTP Server SMTP and POP Servers can be the same system Sending MailRetrieving Mail SMTP Relay SMTP Connection POP Connection Receiving Mail MUA MTA MDA MUA Sample Exchange: Sending, Receiving and Retrieving Electronic Mail

18 SMTP The SMTP protocol defines the method by which mail is sent from one host to another. SMTP usually uses port 25 – mail servers will be “listening” for incoming mail messages. No authentication required to use SMTP services – anybody can send mail without providing a username/password to send it.

19 Sample SMTP Exchange with a Mail Server amenti 5.5 [~] > telnet internet.rutgers.edu 25 Trying 165.230.30.68... Connected to iti.Rutgers.EDU. Escape character is '^]'. 220 iti.rutgers.edu ESMTP Sendmail 8.9.3/8.8.7; Mon, 15 May 2000 20:32:48 -0400 helo foobar.com 250 iti.rutgers.edu Hello amenti.rutgers.edu [165.230.116.133], pleased to meet you mail from: kkaplan@foobar.com 250 kkaplan@foobar.com... Sender ok rcpt to: kkaplan@rci.rutgers.edu 551 we do not relay rcpt to: kkaplan@internet.rutgers.edu 250 kkaplan@internet.rutgers.edu... Recipient ok data 354 Enter mail, end with "." on a line by itself This is a test.. 250 UAA03425 Message accepted for delivery

20 Exercise: Sending a Message Log into iti.rutgers.edu using ssh. Telnet to port 25 on your iti.rutgers.edu: > telnet iti.rutgers.edu 25 Compose and send out an email message: helo foobar.com mail from: foo@foobar.com rcpt to: youritiname@iti.rutgers.edu data This is a test.. ] Verify that your message was received: > less /var/spool/mail/youritiname Try reading the message in pine. type: > pine Access your inbox. What information about the message is hidden from the typical user view?

21 Sendmail Can be downloaded from http://www.sendmail.org. http://www.sendmail.org Started from /etc/rc.d/init.d/sendmail at boot time. Responsible for sending and receiving email messages. Once mail is received, it gets passed off to a MDA to deliver message to appropriate user mail box.

22 Sendmail Components /usr/sbin/sendmail Sendmail binary. Started by default with options –bd –q1h. Sendmail is started by an rc script when system boots. /etc/sendmail.cf Main configuration file. Defines rule sets that dictate Sendmail's behavior. Often also points to other sendmail configuration files in /etc. /etc/aliases or /etc/mail/aliases Used to create mailing lists or to give users alternative email address. /var/spool/mqueue Queue for outgoing email messages.

23 Receiving Electronic Mail The default storage location for incoming mail is /var/spool/mail/username. Mail can be redirected to other local or remote email address through.forward files in user home directories or /etc/aliases on a system level.

24 Aliases File Entry format: username: newuser groupname: user1, user2 Sample enties: root: kkaplan@internet.rutgers.edu staff: kkaplan,jsmith,jdoe After editing /etc/aliases, for changes to take effect, need to run: > /usr/bin/newaliases

25 Exercise: Creating Aliases Add the following entries to /etc/aliases: root: student, youremail@domain.com Type: > /usr/bin/newaliases Verify that your aliases are working: > echo “checking aliases” |/bin/mail root > cat /var/spool/mail/student

26 Retrieving and Reading Email SMTP is a transport mechanism for sending mail only. An SMTP server will not allow a user to read or retrieve his/her mail. Options for reading or retrieving email: –Use a MUA to access directly the file system where the incoming mail is stored. –Post Office Protocol (POP) – permits mail to be downloading from a POP server to a POP client. –Internet Message Access Protocol (IMAP) – IMAP server maintains a central repository for IMAP account mail messages. Users can read, write, and file messages using an IMAP client.

27 POP3 Uses a server process to handle requests to retrieve email. Usually uses port 110. Unlike SMTP, POP is an authenticated protocol. (users must provide a username and password to retrieve mail) Installed by default and enabled on most UNIX systems

28 IMAP Very similar to POP – however, not yet as popular. Uses a server process to handle requests to retrieve email. Usually uses port 143. IMAP is an authenticated protocol. (users must provide a username and password to retrieve mail) Installed by default and enabled on most UNIX systems.

29 Job Scheduling in UNIX Sometimes its desirable to schedule an application or script to execute unattended at a certain time of day or at a certain frequency. –System backups (backup the /home filesystem to tape every night at 2:00am) –Scripts that check system files (check to see if the /etc/password and and /etc/shadow files have been changed in the last 24 hours and email me if they have) –Scripts that mail reports or log files (email me the last 200 lines of the system security log every morning) UNIX administrators need a reliable way to schedule unattended jobs and, possibly, give users the ability to schedule unattended jobs.


Download ppt "ITI-481: Unix Administration Meeting 5 Christopher Uriarte Rutgers University Center for Applied Computing Technologies."

Similar presentations


Ads by Google