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.
Log into your desktopX machine as student and
open a terminal window.
Schedule a task for three minutes in the future. The task should
write a timestamp to /home/student/myjob.
[student@desktopX ~]$echo "date > ~/myjob" | at now +3min
Inspect the list of tasks scheduled for execution in the future for your user.
[student@desktopX ~]$atq1 Thu Jan 30 05:13:00 2014 a student
Wait for your job to run, then inspect the contents of
/home/student/myjob.
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
[student@desktopX ~]$cat myjob
Schedule a job to run at 16:00 tomorrow, using the
g queue. This job should create a new file called
/home/student/tea.
[student@desktopX ~]$at -q g teatime tomorrowat>touch /home/student/teaat>Ctrl+D
Schedule a job, this time in the b queue, to run at
16:05 tomorrow. This job should create the file
/home/student/cookies.
[student@desktopX ~]$at -q b 16:05 tomorrowat>touch /home/student/cookiesat>Ctrl+D
Inspect your pending jobs. Inspect the actual commands your jobs will run as well.
[student@desktopX ~]$atq2 Fri Jan 31 16:00:00 2014 g student 3 Fri Jan 31 16:05:00 2014 b student
[student@desktopX ~]$at -c 2[student@desktopX ~]$at -c 3
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).
[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.