User Tools

Site Tools


haas:spring2020:unix:cs:cs7


Corning Community College


UNIX/Linux Fundamentals



Case Study 0x7: Scheduled Tasks

~~TOC~~

Objective

To gain some familiarity with the task scheduling facilities on the system.

Background

To most of us, computers are a frequently used interactive tool for accomplishing work. With our recent explorations into the realm of shell scripting, concepts of automation are starting to enter our peripherary.

With automation, comes the need to do things outside that interactive environment, and run at a designated time or in reaction to a particular event.

We will be scheduling tasks with respect to time in this case study, to get better acquainted with the functionality and capabilities of non-interactive yet automated tasks.

cron

From the wikipedia article on Cron:

“Cron is a time-based job scheduler in Unix-like computer operating systems. The name cron comes from the word “chronos”, Greek for “time”. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. It is commonly used to automate system maintenance or administration, though its general-purpose nature means that it can be used for other purposes, such as connecting to the Internet and downloading email.”

Be sure to check the manual page for cron(8), and the corresponding manual pages for crontab(1) and crontab(5). When you are familiar with where pertinent information can be found regarding cron, proceed to the question below.

activity

1. Configure and deploy your own irc bot:
a.Locate, download, extract, and read the directions (README.txt) for the phenny irc bot.
b.Be sure to configure it properly (give it a unique name), make sure it can recognize you, and connect successfully to the LAIR's irc server (irc.offbyone.lan). Have it join the channel #botchan; please keep it out of regular class channels.
c.Run the bot, and verify that it can successfully join #botchan on irc. (You'll want to do a “/join botchan” before getting to this step, and also obviously use you existing screened irssi session).
d.What is the name of your bot?
e.Interact with the bot, give it some commands. Verify that it works.
f.Write about your experiences on your Opus.
g.Collaboratively with the rest of the class, create/enhance a Phenny tutorial on the UNIX notes page. include instructions for obtaining, configuring, information on deploying and using various modules. Each person should contribute some unique bit of information regarding the functionality of the bot.
h.What topic did you contribute to the class Phenny tutorial?

A Google search should be adequate in locating Phenny on the internet. From my searching, there would seem to be 2 sites of note:

I also found a few sites offering additional modules for Phenny. A couple are listed here:

2. Write a script to do the following:
a.Using pgrep(1) or a related process status command, find the PID(s) of your bot.
b.If no PIDs are found, launch the bot.
c.Paste your script into this form on the submission page.

You'll want to probably test some things out on the command-line first… observe process behavior when the bot is and is not running.

The script you are writing is to be used to automatically restart the bot in the event of a server restart or if the bot terminates for whatever reason.

3. Taking your newfound knowledge of cron:
a.Deploy a crontab entry that will run your script every 20 minutes of every hour of every day.
b.Terminate your bot, and wait for the next window to see if your cron task automatically runs your script, and successfully reconnects your bot.
c.Paste your crontab entry into this form on the submission page.
d.After this assignment is due, if you no longer wish to use your bot, please remove your crontab entry and terminate your bot.

at

From the wikipedia article on at_(Unix):

“In Unix-like computer operating systems, the at command is used to schedule commands to be executed once, at a particular time in the future.”

Like cron, at can be used to schedule tasks. cron tends to be a tool used for regular scheduling of tasks, where at is designed for a one-time scheduled task.

I'd like for you to read through the at(1) manual page and become familiar with the at and related utilities.

When you are familiar, proceed to the question.

4. Using at:
a.Deploy a job that sends a simple e-mail to you 5 minutes from now (check out the mail(1) command).
b.What does your job look like (actual command logic that is run to send mail)?
c.Deploy a second, identical job, that also runs 5 minutes from now.
d.Using atrm, remove the first job from the at queue. Show me how you did this.
e.Deploy an at job to send you a reminder e-mail on the morning of the Friday this assignment is due.
f.Show me how you scheduled your at job.

Conclusions

This assignment has activities which you should tend to- document/summarize knowledge learned on your Opus.

As always, the class mailing list and class IRC channel are available for assistance, but not answers.

haas/spring2020/unix/cs/cs7.txt · Last modified: 2013/10/16 08:28 by 127.0.0.1