Bookmark this page

Practice: Scheduling One-Time Tasks with at

In this lab, you will schedule one-time tasks for the future.

Resources
Machines: desktopX

Outcomes

Three jobs scheduled for the future, with one executed, and two removed again.

  1. Log into your desktopX machine as student and open a terminal window.

  2. Schedule a task for three minutes in the future. The task should write a timestamp to /home/student/myjob.

    1. [student@desktopX ~]$ echo "date > ~/myjob" | at now +3min
  3. Inspect the list of tasks scheduled for execution in the future for your user.

    1. [student@desktopX ~]$ atq
      1       Thu Jan 30 05:13:00 2014 a student
  4. Wait for your job to run, then inspect the contents of /home/student/myjob.

    1. Repeatedly run atq until your job disappears from the list, or (if you only have one pending job and like scripting):

      [student@desktopX ~]$ while [ $(atq | wc -l) -gt 0 ]; do sleep 1s; done
    2. [student@desktopX ~]$ cat myjob
  5. Schedule a job to run at 16:00 tomorrow, using the g queue. This job should create a new file called /home/student/tea.

    1. [student@desktopX ~]$ at -q g teatime tomorrow
      at> touch /home/student/tea
      at> Ctrl+D
  6. Schedule a job, this time in the b queue, to run at 16:05 tomorrow. This job should create the file /home/student/cookies.

    1. [student@desktopX ~]$ at -q b 16:05 tomorrow
      at> touch /home/student/cookies
      at> Ctrl+D
  7. Inspect your pending jobs. Inspect the actual commands your jobs will run as well.

    1. [student@desktopX ~]$ atq
      2       Fri Jan 31 16:00:00 2014 g student
      3       Fri Jan 31 16:05:00 2014 b student
    2. [student@desktopX ~]$ at -c 2
      [student@desktopX ~]$ at -c 3
      
  8. You have decided you don't actually like tea that much. Remove the job that writes the file /home/student/tea, but keep the job that writes /home/student/cookies (you like cookies).

    1. [student@desktopX ~]$ atrm 2

      Important: If your job to write /home/student/tea had a different number than 2, use that number in the previous command.

Revision: rh134-7-c643331