puflogh300X74.gif

Polarwave's OpenBSD
Tips and Tricks for Newbies

| Simple Homemade Scheduler |

| Home | Tips and Tricks | Links | News Feeds | Fun | Contact | Blog (Opens in New Page) |


Scheduling

Free, Fast, & Simple Homemade Scheduler

Everyone who uses any of the "nix's probably has used crontab at one time or another.
It's great for setting up recurring events. But, suppose you've got an an upcoming
appointment that's just a one-time event? Until recently, I'd never used the at(1)
command, but now I do to create simple reminders for myself. It began when I got a
letter from the VA where I go for checkups. They sent me a letter letting me know I
had an upcoming doctor's appointment. I started to go to my Yahoo account to write
myself a reminder on the calendar to be emailed a day before the appointment. I got
to thinking, let me see if I can do it the "nix" way. I didn't realize at the time that it
would be automatically emailed to me when at ran the command, so I created a text
file with all the pertinent information, and then wrote a short script to be called by
the at program at the prescribed time. It looked something like this:

Contents of text file:

VA Appointment - date of appointment
Time - Where
Preappointment requirements
Side note from myself

Contents of script to be run using the at program:

#!/bin/sh
#
# VA Appointment Reminder
#
cat $HOME/textfile | mail -s "`bin/hostname` VA Appointment" username

Then, run at hitting a CR or Enter after each line except the final Ctrl-D:

$ at 6am Mar 25
  $HOME/scriptname
  Ctrl-D
  commands will be executed using /bin/ksh
  job 1206158400.c at Tue Mar 25 06:00:00 2008
  (those last 2 lines are the output from at. After
  that, you're returned to the prompt)
I went ahead and ran the script manually to make sure it ran correctly. Then, to
check the at job, from the command prompt, I ran:
$ at -l

and I got:

$ 1206442800.c    Tue Mar 25 06:00:00 2008
Then I started playing around with at, running simple things like
$ at 1am
  echo "Get your butt in bed, old man, it's late!"
  Ctrl-D
still not really knowing all I was soon to find out about at. I was expecting it to
show up on the screen, but instead it was emailed to my local user account.
Date: Mon, Mar 2008 01:00:00 -0500 (CDT)
From: Atrun Service <username@localbox.isp.net>
To: username@localbox.isp.net
Subject: Output from "at" job

Your "at" job on localbox.isp.net
"/var/cron/atjobs/1206141180.c"

produced the following output:

Get your butt in bed, old man, it's late!
Now I realized I didn't need an external script or text file message for something
this simple. I could do it all from right inside of at, pressing a CR or Enter after
each line except the final one where you hit Ctrl-D:
$ at 6am Mar 25
  echo "VA Appointment - date of appointment"
  echo "Time - Where"
  echo (make empty space here for separation & readability)
  echo "Preappointment requirements"
  echo (another empty space to separate note elements)
  echo "Side notes for myself"
  Ctrl-D
  (I omitted the output from at here. Example is shown above)
So, give at a try. Read the man page, experiment, and have some fun!

Back to Tips and Tricks
Home

Delicious Bookmark this on Delicious

No affiliation between this site and the OpenBSD project exists or is implied.

valid-html401.png