<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000'><div>Hm. Interesting question. I have noticed that, but I just assumed it was a newbie mistake, or an oldbie trying to make an article friendly to DOS/Windows users. But, now that I think about it, it doesn't make sense. Any newbie that is going to use the Linux shell successfully, can make the leap between command shell prompts; it's not that hard.</div><div><br></div><div>I wonder if there is any distro or Bash install that defaults to '>' rather than '$' and '#'... I don't have a Windows box handy, but I wonder about Bash in CygWin and Git. How's it set up?</div><div><br></div><div><span name="x"></span>--<br>David L. Willson<br>Teacher, Engineer, Evangelist<br>COA LFCS CCAH RHCE CLP<br>Mobile 720-333-LANS(5267)<br>http://sofree.us<br><br>This is a good time for a r3VOLution.<span name="x"></span><br></div><br><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div dir="ltr">It confuses me when linux/unix groups use the`>_` in icons to mean linux. Where is that a default prompt on a linux/unix system?<div>It is the default prompt on dos other than the "drive spec" that usually precedes it..</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Dec 14, 2018 at 7:56 AM DLWillson <<a href="mailto:DLWillson@thegeek.nu" target="_blank">DLWillson@thegeek.nu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<div>Highly enjoyable. Today it's at.</div><div><br></div><div><br></div><div id="gmail-m_3897000221970399652composer_signature"><div style="font-size:88%;color:rgb(54,79,103)">David L. Willson</div><div style="font-size:88%;color:rgb(54,79,103)">720-333-LANS</div></div><br><br>-------- Original message --------<br>From: Linux Journal <<a href="mailto:subs@linuxjournal.com" target="_blank">subs@linuxjournal.com</a>> <br>Date: 12/14/18 5:30 AM (GMT-07:00) <br>To: <a href="mailto:dlwillson@thegeek.nu" target="_blank">dlwillson@thegeek.nu</a> <br>Subject: 12 DAYS OF LINUX TECH TIPS #8 <br><br>
<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f2f2f2">
<tbody><tr>
<td valign="top" align="center">
<table class="gmail-m_3897000221970399652mobile-shell" width="650" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652td" style="width:650px;min-width:650px;font-size:0pt;line-height:0pt;padding:0px;margin:0px;font-weight:normal">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652header" style="padding:60px 0px 40px">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<th class="gmail-m_3897000221970399652column-bottom" style="font-size:0pt;line-height:0pt;padding:0px;margin:0px;font-weight:normal;vertical-align:bottom" width="261">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652text-header" style="color:rgb(0,0,0);font-family:"Open Sans",Arial,sans-serif;font-size:12px;line-height:16px;text-align:left;font-weight:bold;text-transform:uppercase"><p style="padding:0px;margin:0px">
12 Days of Tech Tips #8</p>
</td>
</tr>
</tbody></table>
</th>
<th class="gmail-m_3897000221970399652column-empty" style="font-size:0pt;line-height:0pt;padding:0px;margin:0px;font-weight:normal;vertical-align:top" width="1"></th>
<th class="gmail-m_3897000221970399652column" style="font-size:0pt;line-height:0pt;padding:0px;margin:0px;font-weight:normal" width="125">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652img-center" style="font-size:0pt;line-height:0pt;text-align:center"><a href="https://linuxjournal.cmail19.com/t/j-l-phdtkkl-jrhdlhhdjy-j/" style="color:rgb(220,36,39);text-decoration:none" target="_blank"><img id="gmail-m_38970002219703996521544799306064" src="http://i8.cmail19.com/ti/j/24/755/399/051327/images/logo.jpg" width="125" border="0"></a></td>
</tr>
</tbody></table>
</th>
<th class="gmail-m_3897000221970399652column-empty" style="font-size:0pt;line-height:0pt;padding:0px;margin:0px;font-weight:normal;vertical-align:top" width="1"></th>
<th class="gmail-m_3897000221970399652column-bottom" style="font-size:0pt;line-height:0pt;padding:0px;margin:0px;font-weight:normal;vertical-align:bottom" width="262">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652text-header gmail-m_3897000221970399652right" style="color:rgb(0,0,0);font-family:"Open Sans",Arial,sans-serif;font-size:12px;line-height:16px;font-weight:bold;text-transform:uppercase;text-align:right"><a href="https://linuxjournal.cmail19.com/t/j-e-phdtkkl-jrhdlhhdjy-n/" class="gmail-m_3897000221970399652link" style="color:rgb(220,36,39);text-decoration:none" target="_blank">view in browser »</a></td>
</tr>
</tbody></table>
</th>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td class="gmail-m_3897000221970399652main" style="padding:50px 0px 0px" bgcolor="#ffffff">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652head" style="padding:15px 50px;border-top:1px solid rgb(242,242,242);border-bottom:1px solid rgb(242,242,242);color:rgb(0,0,0);font-family:"Open Sans",Arial,sans-serif;font-size:16px;line-height:24px;text-align:center;text-transform:uppercase;font-weight:bold">
<p style="padding:0px;margin:0px">
<span style="font-size:22px"><strong>12 DAYS OF LINUX TECH TIPS FOR YOU THIS HOLIDAY SEASON! JOIN US TODAY FOR TECH TIP #8</strong></span></p>
</td>
</tr>
</tbody></table>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652section" style="padding:0px 50px 40px">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652fluid-img gmail-m_3897000221970399652pb30" style="font-size:0pt;line-height:0pt;text-align:left;padding-bottom:30px"><a href="https://linuxjournal.cmail19.com/t/j-l-phdtkkl-jrhdlhhdjy-t/" style="color:rgb(220,36,39);text-decoration:none" target="_blank"><img alt="Terminal" id="gmail-m_38970002219703996521544799306065" src="http://i1.cmail19.com/ei/j/C6/11F/472/csimport/bigstock--187641571_0.153221.jpg" width="549" height="322" border="0"></a></td>
</tr>
<tr>
<td class="gmail-m_3897000221970399652h2 gmail-m_3897000221970399652center gmail-m_3897000221970399652pb10" style="color:rgb(0,0,0);font-family:Lateef,Georgia,serif;font-size:40px;line-height:44px;text-align:center;padding-bottom:10px"><p style="padding:0px;margin:0px">
Schedule One-Time Commands with the UNIX at Tool</p>
</td>
</tr>
<tr>
<td class="gmail-m_3897000221970399652text2 gmail-m_3897000221970399652center gmail-m_3897000221970399652pb25" style="color:rgb(119,119,119);font-family:"Open Sans",Arial,sans-serif;font-size:12px;line-height:16px;font-style:italic;text-align:center;padding-bottom:25px"><p style="padding:0px;margin:0px">
Kyle Rankin</p>
</td>
</tr>
<tr>
<td class="gmail-m_3897000221970399652text gmail-m_3897000221970399652pb40" style="color:rgb(40,40,40);font-family:"Open Sans",Arial,sans-serif;font-size:14px;line-height:24px;text-align:left;padding-bottom:40px">
<p style="padding:0px;margin:0px"><em>Cron is nice and all, but don't forget about its cousin <code>at</code>.</em></p><br>
<p style="padding:0px;margin:0px">
When I first started using Linux, it was like being tossed into the deep end
of the UNIX pool. You were expected to use the command line heavily along
with all the standard utilities and services that came with your
distribution. At lot has changed since then, and nowadays, you can use a
standard Linux desktop without ever having to open a terminal or use old
UNIX services. Even as a sysadmin, these days, you often are a few layers of
abstraction above some of these core services.
</p><br>
<p style="padding:0px;margin:0px">
I say all of this to point out that for us old-timers, it's easy to take for
granted that everyone around us innately knows about all the command-line
tools we use. Yet, even though I've been using Linux for 20 years, I
still learn about new (to me) command-line tools all the time. In this "Back
to Basics" article series, I plan to cover some of the command-line tools
that those new to Linux may never have used before. For those of you who are
more advanced, I'll spread out this series, so you can expect future
articles to be more technical. In this article, I describe how to use
the <code>at</code> utility to schedule jobs to run at a later date.
</p>
<h3>
<code>at</code> vs. Cron</h3>
<p style="padding:0px;margin:0px">
<code>at</code> is one of those commands that isn't discussed very much. When
people talk about scheduling commands, typically cron gets the most
coverage. Cron allows you to schedule commands to be run on a periodic
basis. With cron, you can run a command as frequently as every minute or as
seldom as once a day, week, month or even year. You also can define more
sophisticated rules, so commands run, for example, every five minutes, every
weekday, every other hour and many other combinations. System administrators sometimes
will use cron to schedule a local script to collect metrics every minute or
to schedule backups.
</p><br>
<p style="padding:0px;margin:0px">
On the other hand, although the <code>at</code> command also allows you to schedule
commands, it serves a completely different purpose from cron. While cron
lets you schedule commands to run periodically, <code>at</code> lets you schedule
commands that run only once at a particular time in the future. This
means that <code>at</code> fills a different and usually more immediate need
from cron.
</p>
<h3>
Using <code>at</code></h3>
<p style="padding:0px;margin:0px">
At one point, the <code>at</code> command came standard on most Linux
distributions, but
these days, even on servers, you may find yourself having to
install the <code>at</code> package explicitly. Once installed, the easiest
way to use <code>at</code> is to type
it on the command line followed by the time you want the command to run:
</p><pre><code>
$ at 18:00
</code>
</pre>
<p style="padding:0px;margin:0px"></p>
<p style="padding:0px;margin:0px">
The <code>at</code> command also can accept a number of different time formats. For
instance, it understands AM and PM as well as words like "tomorrow", so you
could replace the above command with the identical:
</p><pre><code>
$ at 6pm
</code>
</pre>
<p style="padding:0px;margin:0px"></p>
<p style="padding:0px;margin:0px">
And, if you want to run the same command at that time tomorrow instead:
</p><pre><code>
$ at 6pm tomorrow
</code>
</pre>
<p style="padding:0px;margin:0px"></p>
<p style="padding:0px;margin:0px">
Once you press enter, you'll drop into an interactive shell:
</p><pre><code>
$ at 6pm tomorrow
warning: commands will be executed using /bin/sh
at>
</code>
</pre>
<p style="padding:0px;margin:0px"></p>
<p style="padding:0px;margin:0px">
>From the interactive shell, you can enter the command you want to run
at that time. If you want to run multiple commands, press enter after each
command and type the command on the new <code>at></code> prompt. Once you're done
entering commands, press Ctrl-D on an empty <code>at></code> prompt to exit the
interactive shell.
</p><br>
<p style="padding:0px;margin:0px">
For instance, let's say I've noticed that a particular server has had
problems the past two days at 5:10am for around five minutes, and so far, I'm
not seeing anything in the logs. Although I could just wake up early and log
in to the server, instead I could write a short script that collects data
from <code>ps</code>, <code>netstat</code>, <code>tcpdump</code> and other
command-line tools for a few minutes, so
when I wake up, I can go over the data it collected. Since this is a one-off,
I don't want to schedule something with cron and risk forgetting about it
and having it run every day, so this is how I would set it up with
<code>at</code>:
</p><pre><code>
$ at 5:09am tomorrow
warning: commands will be executed using /bin/sh
at>
at> /usr/local/bin/my_monitoring_script
</code>
</pre>
<p style="padding:0px;margin:0px"></p>
<p style="padding:0px;margin:0px">
Then I would press Ctrl-D, and the shell would exit with this output:
</p><pre><code>
at> <EOT>
job 1 at Wed Sep 26 05:09:00 2018
</code>
</pre>
<p style="padding:0px;margin:0px"></p>
<h3>
Managing <code>at</code> Jobs</h3>
<p style="padding:0px;margin:0px">
Once you have scheduled <code>at</code> jobs, it's useful to be able to pull up a list of
all the <code>at</code> jobs in the queue, so you know what's running and
when. The <code>atq</code>
command lists the current <code>at</code> queue:
</p><pre><code>
$ atq
1 Wed Sep 26 05:09:00 2018 a kyle
</code>
</pre>
<p style="padding:0px;margin:0px"></p>
<p style="padding:0px;margin:0px">
The first column lists the number <code>at</code> assigned to each job and then lists the
time the job will be run and the user it will run as. Let's say that in
the above example I realize I've made a mistake, because my script won't be able
to run as a regular user. In that case, I would want to use the
<code>atrm</code> command
to remove job number 1:
</p><pre><code>
$ atrm 1
</code>
</pre>
<p style="padding:0px;margin:0px"></p>
<p style="padding:0px;margin:0px">
If I were to run <code>atq</code> again, I would see that the job no longer exists.
Then I could <code>sudo</code> up to root and use the <code>at</code> command to schedule the job
again.
</p>
<h3>
<code>at</code> One-Liners</h3>
<p style="padding:0px;margin:0px">
Although <code>at</code> supports an interactive mode, you also can pipe commands to it all
on one line instead. So, for instance, I could schedule the above job with:
</p><pre><code>
$ echo /usr/local/bin/my_monitoring_script | at 5:09am tomorrow
</code>
</pre>
<p style="padding:0px;margin:0px"></p>
<h3>
Conclusion</h3>
<p style="padding:0px;margin:0px">
If you didn't know that <code>at</code> existed, you might find yourself coming up with
all sorts of complicated and convoluted ways to schedule a one-off job. Even
worse, you might need to set an alarm clock so you can wake up extra early
and log in to a problem server. Of course, if you don't have an alarm clock,
you could use <code>at</code>:
</p><pre><code>
$ echo "aplay /home/kyle/alarm.wav" | at 7am tomorrow
</code>
</pre>
<p style="padding:0px;margin:0px"></p>
</td>
</tr>
<tr>
<td align="center">
<table class="gmail-m_3897000221970399652center" style="text-align:center" cellspacing="0" cellpadding="0" border="0" bgcolor="#dc2427">
<tbody><tr>
<td class="gmail-m_3897000221970399652text-button" style="color:rgb(255,255,255);font-family:"Open Sans",Arial,sans-serif;font-size:16px;line-height:24px;text-align:center;text-transform:uppercase;font-weight:bold;padding:12px 30px;background-color:rgb(220,36,39);background-image:none;background-repeat:repeat;background-position:0% 0%"><p style="padding:0px;margin:0px">
<a class="gmail-m_3897000221970399652link-white" href="https://linuxjournal.cmail19.com/t/j-l-phdtkkl-jrhdlhhdjy-i/" style="color:rgb(255,255,255);text-decoration:none" target="_blank"><span class="gmail-m_3897000221970399652link-white" style="color:rgb(255,255,255);text-decoration:none">read more articles</span></a></p>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652section3" style="padding:40px 50px" bgcolor="#fafafa">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<th class="gmail-m_3897000221970399652column" style="font-size:0pt;line-height:0pt;padding:0px;margin:0px;font-weight:normal">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652h4 gmail-m_3897000221970399652pb15" style="color:rgb(0,0,0);font-family:Lateef,Georgia,serif;font-size:26px;line-height:30px;text-align:left;padding-bottom:15px"><p style="padding:0px;margin:0px">
Subscribe to Linux Journal for only $2.88 an issue!</p>
</td>
</tr>
<tr>
<td class="gmail-m_3897000221970399652text" style="color:rgb(40,40,40);font-family:"Open Sans",Arial,sans-serif;font-size:14px;line-height:24px;text-align:left"><p style="padding:0px;margin:0px">
<a class="gmail-m_3897000221970399652link" href="https://linuxjournal.cmail19.com/t/j-l-phdtkkl-jrhdlhhdjy-d/" style="color:rgb(220,36,39);text-decoration:none" target="_blank"><span class="gmail-m_3897000221970399652link" style="color:rgb(220,36,39);text-decoration:none">Subscribe Now »</span></a></p>
<p style="padding:0px;margin:0px">
<a class="gmail-m_3897000221970399652link" href="https://linuxjournal.cmail19.com/t/j-l-phdtkkl-jrhdlhhdjy-h/" style="color:rgb(220,36,39);text-decoration:none" target="_blank"><span class="gmail-m_3897000221970399652link" style="color:rgb(220,36,39);text-decoration:none">Renew now »</span></a></p>
</td>
</tr>
</tbody></table>
</th>
<th class="gmail-m_3897000221970399652column-empty" style="font-size:0pt;line-height:0pt;padding:0px;margin:0px;font-weight:normal;vertical-align:top" width="20"></th>
<th class="gmail-m_3897000221970399652column" style="font-size:0pt;line-height:0pt;padding:0px;margin:0px;font-weight:normal" width="336">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652fluid-img" style="font-size:0pt;line-height:0pt;text-align:left"><img id="gmail-m_38970002219703996521544799306065" src="http://i2.cmail19.com/ei/j/C6/11F/472/csimport/LJ293-Dec2018-Cover.131504.jpg" width="336" height="449" border="0"></td>
</tr>
</tbody></table>
</th>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652footer" style="padding:50px 40px">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652img-center gmail-m_3897000221970399652pb30" style="font-size:0pt;line-height:0pt;text-align:center;padding-bottom:30px"><a href="https://linuxjournal.cmail19.com/t/j-l-phdtkkl-jrhdlhhdjy-k/" style="color:rgb(220,36,39);text-decoration:none" target="_blank"><img id="gmail-m_38970002219703996521544799306065" src="http://i1.cmail19.com/ti/j/24/755/399/051327/images/footer_logo.jpg" width="104" border="0"></a></td>
</tr>
<tr>
<td class="gmail-m_3897000221970399652pb30" style="padding-bottom:30px" align="center">
<table cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td class="gmail-m_3897000221970399652img" style="font-size:0pt;line-height:0pt;text-align:left" width="56"><a href="https://linuxjournal.cmail19.com/t/j-l-phdtkkl-jrhdlhhdjy-u/" style="color:rgb(220,36,39);text-decoration:none" target="_blank"><img id="gmail-m_38970002219703996521544799306068" src="http://i3.cmail19.com/ti/j/24/755/399/051327/images/ico_youtube.jpg" width="42" border="0"></a></td>
<td class="gmail-m_3897000221970399652img" style="font-size:0pt;line-height:0pt;text-align:left" width="56"><a href="https://linuxjournal.cmail19.com/t/j-l-phdtkkl-jrhdlhhdjy-o/" style="color:rgb(220,36,39);text-decoration:none" target="_blank"><img id="gmail-m_38970002219703996521544799306068" src="http://i2.cmail19.com/ti/j/24/755/399/051327/images/ico_facebook.jpg" width="42" border="0"></a></td>
<td class="gmail-m_3897000221970399652img" style="font-size:0pt;line-height:0pt;text-align:left" width="42"><a href="https://linuxjournal.cmail19.com/t/j-l-phdtkkl-jrhdlhhdjy-b/" style="color:rgb(220,36,39);text-decoration:none" target="_blank"><img id="gmail-m_38970002219703996521544799306068" src="http://i4.cmail19.com/ti/j/24/755/399/051327/images/ico_twitter.jpg" width="42" border="0"></a></td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td class="gmail-m_3897000221970399652text-footer gmail-m_3897000221970399652pb25" style="color:rgb(40,40,40);font-family:"Open Sans",Arial,sans-serif;font-size:12px;line-height:22px;text-align:center;padding-bottom:25px">
<p style="padding:0px;margin:0px">
You are receiving this email because you signed up to receive newsletters from <em>Linux Journal</em>.</p>
<div>You can <a href="https://linuxjournal.updatemyprofile.com/j-phdtkkl-08368EA2-jrhdlhhdjy-r" class="gmail-m_3897000221970399652link" style="color:rgb(220,36,39);text-decoration:none" target="_blank">update your preferences</a> or <a href="https://linuxjournal.cmail19.com/t/j-u-phdtkkl-jrhdlhhdjy-y/" class="gmail-m_3897000221970399652link" style="color:rgb(220,36,39);text-decoration:none" target="_blank">unsubscribe</a> from this list. </div>
</td>
</tr>
<tr>
<td class="gmail-m_3897000221970399652text-footer" style="color:rgb(40,40,40);font-family:"Open Sans",Arial,sans-serif;font-size:12px;line-height:22px;text-align:center">
<p style="padding:0px;margin:0px">
Copyright © 2018 Linux Journal LLC, All rights reserved.<br>
Mailing address: 9597 Jones Rd, #331 Houston, TX 77065</p>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td class="gmail-m_3897000221970399652pb40 gmail-m_3897000221970399652np" style="padding-bottom:40px"></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<img alt="" style="display: block; height: 1px; width: 1px; border-width: 0px; margin: 0px; padding: 0px;" id="gmail-m_38970002219703996521544799306068" src="https://linuxjournal.cmail19.com/t/j-o-phdtkkl-jrhdlhhdjy/o.gif" width="1" height="1" border="0"></div>_______________________________________________<br>
SFS mailing list<br>
<a href="mailto:SFS@lists.sofree.us" target="_blank">SFS@lists.sofree.us</a><br>
<a href="http://lists.sofree.us/cgi-bin/mailman/listinfo/sfs" rel="noreferrer" target="_blank">http://lists.sofree.us/cgi-bin/mailman/listinfo/sfs</a><br>
</blockquote></div>
</blockquote><br></div></body></html>