~ubuntu-branches/ubuntu/trusty/abs-guide/trusty-proposed

« back to all changes in this revision

Viewing changes to HTML/timedate.html

  • Committer: Package Import Robot
  • Author(s): Sandro Tosi
  • Date: 2012-06-03 10:57:27 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20120603105727-rm7frl4feikr2swm
Tags: 6.5-1
* New upstream release
* debian/watch
  - updated
* debian/abs-guide.lintian-overrides
  - updated for new upstream code
* debian/control
  - bump Standards-Version to 3.9.3 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
2
<HTML
 
3
><HEAD
 
4
><TITLE
 
5
>Time / Date Commands</TITLE
 
6
><META
 
7
NAME="GENERATOR"
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
 
9
"><LINK
 
10
REL="HOME"
 
11
TITLE="Advanced Bash-Scripting Guide"
 
12
HREF="index.html"><LINK
 
13
REL="UP"
 
14
TITLE="External Filters, Programs and Commands"
 
15
HREF="external.html"><LINK
 
16
REL="PREVIOUS"
 
17
TITLE="Complex Commands"
 
18
HREF="moreadv.html"><LINK
 
19
REL="NEXT"
 
20
TITLE="Text Processing Commands"
 
21
HREF="textproc.html"><META
 
22
HTTP-EQUIV="Content-Style-Type"
 
23
CONTENT="text/css"><LINK
 
24
REL="stylesheet"
 
25
HREF="common/kde-common.css"
 
26
TYPE="text/css"><META
 
27
HTTP-EQUIV="Content-Type"
 
28
CONTENT="text/html; charset=iso-8859-1"><META
 
29
HTTP-EQUIV="Content-Language"
 
30
CONTENT="en"><LINK
 
31
REL="stylesheet"
 
32
HREF="common/kde-localised.css"
 
33
TYPE="text/css"
 
34
TITLE="KDE-English"><LINK
 
35
REL="stylesheet"
 
36
HREF="common/kde-default.css"
 
37
TYPE="text/css"
 
38
TITLE="KDE-Default"></HEAD
 
39
><BODY
 
40
CLASS="SECT1"
 
41
BGCOLOR="#FFFFFF"
 
42
TEXT="#000000"
 
43
LINK="#AA0000"
 
44
VLINK="#AA0055"
 
45
ALINK="#AA0000"
 
46
STYLE="font-family: sans-serif;"
 
47
><DIV
 
48
CLASS="NAVHEADER"
 
49
><TABLE
 
50
SUMMARY="Header navigation table"
 
51
WIDTH="100%"
 
52
BORDER="0"
 
53
CELLPADDING="0"
 
54
CELLSPACING="0"
 
55
><TR
 
56
><TH
 
57
COLSPAN="3"
 
58
ALIGN="center"
 
59
>Advanced Bash-Scripting Guide: An in-depth exploration of the art of shell scripting</TH
 
60
></TR
 
61
><TR
 
62
><TD
 
63
WIDTH="10%"
 
64
ALIGN="left"
 
65
VALIGN="bottom"
 
66
><A
 
67
HREF="moreadv.html"
 
68
ACCESSKEY="P"
 
69
>Prev</A
 
70
></TD
 
71
><TD
 
72
WIDTH="80%"
 
73
ALIGN="center"
 
74
VALIGN="bottom"
 
75
>Chapter 16. External Filters, Programs and Commands</TD
 
76
><TD
 
77
WIDTH="10%"
 
78
ALIGN="right"
 
79
VALIGN="bottom"
 
80
><A
 
81
HREF="textproc.html"
 
82
ACCESSKEY="N"
 
83
>Next</A
 
84
></TD
 
85
></TR
 
86
></TABLE
 
87
><HR
 
88
ALIGN="LEFT"
 
89
WIDTH="100%"></DIV
 
90
><DIV
 
91
CLASS="SECT1"
 
92
><H1
 
93
CLASS="SECT1"
 
94
><A
 
95
NAME="TIMEDATE"
 
96
></A
 
97
>16.3. Time / Date Commands</H1
 
98
><DIV
 
99
CLASS="VARIABLELIST"
 
100
><P
 
101
><B
 
102
><A
 
103
NAME="TDLISTING1"
 
104
></A
 
105
>Time/date and timing</B
 
106
></P
 
107
><DL
 
108
><DT
 
109
><A
 
110
NAME="DATEREF"
 
111
></A
 
112
><B
 
113
CLASS="COMMAND"
 
114
>date</B
 
115
></DT
 
116
><DD
 
117
><P
 
118
>Simply invoked, <B
 
119
CLASS="COMMAND"
 
120
>date</B
 
121
> prints the date and
 
122
              time to <TT
 
123
CLASS="FILENAME"
 
124
>stdout</TT
 
125
>. Where this command gets
 
126
              interesting is in its formatting and parsing options.</P
 
127
><DIV
 
128
CLASS="EXAMPLE"
 
129
><HR><A
 
130
NAME="EX51"
 
131
></A
 
132
><P
 
133
><B
 
134
>Example 16-10. Using <I
 
135
CLASS="FIRSTTERM"
 
136
>date</I
 
137
></B
 
138
></P
 
139
><TABLE
 
140
BORDER="0"
 
141
BGCOLOR="#E0E0E0"
 
142
WIDTH="90%"
 
143
><TR
 
144
><TD
 
145
><PRE
 
146
CLASS="PROGRAMLISTING"
 
147
>   1&nbsp;#!/bin/bash
 
148
   2&nbsp;# Exercising the 'date' command
 
149
   3&nbsp;
 
150
   4&nbsp;echo "The number of days since the year's beginning is `date +%j`."
 
151
   5&nbsp;# Needs a leading '+' to invoke formatting.
 
152
   6&nbsp;# %j gives day of year.
 
153
   7&nbsp;
 
154
   8&nbsp;echo "The number of seconds elapsed since 01/01/1970 is `date +%s`."
 
155
   9&nbsp;#  %s yields number of seconds since "UNIX epoch" began,
 
156
  10&nbsp;#+ but how is this useful?
 
157
  11&nbsp;
 
158
  12&nbsp;prefix=temp
 
159
  13&nbsp;suffix=$(date +%s)  # The "+%s" option to 'date' is GNU-specific.
 
160
  14&nbsp;filename=$prefix.$suffix
 
161
  15&nbsp;echo "Temporary filename = $filename"
 
162
  16&nbsp;#  It's great for creating "unique and random" temp filenames,
 
163
  17&nbsp;#+ even better than using $$.
 
164
  18&nbsp;
 
165
  19&nbsp;# Read the 'date' man page for more formatting options.
 
166
  20&nbsp;
 
167
  21&nbsp;exit 0</PRE
 
168
></TD
 
169
></TR
 
170
></TABLE
 
171
><HR></DIV
 
172
><P
 
173
>The <TT
 
174
CLASS="OPTION"
 
175
>-u</TT
 
176
> option gives the UTC (Universal
 
177
              Coordinated Time).</P
 
178
><P
 
179
>             <TABLE
 
180
BORDER="0"
 
181
BGCOLOR="#E0E0E0"
 
182
WIDTH="90%"
 
183
><TR
 
184
><TD
 
185
><PRE
 
186
CLASS="SCREEN"
 
187
> <TT
 
188
CLASS="PROMPT"
 
189
>bash$ </TT
 
190
><TT
 
191
CLASS="USERINPUT"
 
192
><B
 
193
>date</B
 
194
></TT
 
195
>
 
196
 <TT
 
197
CLASS="COMPUTEROUTPUT"
 
198
>Fri Mar 29 21:07:39 MST 2002</TT
 
199
>
 
200
 
 
201
 
 
202
 
 
203
 <TT
 
204
CLASS="PROMPT"
 
205
>bash$ </TT
 
206
><TT
 
207
CLASS="USERINPUT"
 
208
><B
 
209
>date -u</B
 
210
></TT
 
211
>
 
212
 <TT
 
213
CLASS="COMPUTEROUTPUT"
 
214
>Sat Mar 30 04:07:42 UTC 2002</TT
 
215
>
 
216
              </PRE
 
217
></TD
 
218
></TR
 
219
></TABLE
 
220
>
 
221
              </P
 
222
><P
 
223
>This option facilitates calculating the time between
 
224
              different dates.</P
 
225
><DIV
 
226
CLASS="EXAMPLE"
 
227
><HR><A
 
228
NAME="DATECALC"
 
229
></A
 
230
><P
 
231
><B
 
232
>Example 16-11. <I
 
233
CLASS="FIRSTTERM"
 
234
>Date</I
 
235
> calculations</B
 
236
></P
 
237
><TABLE
 
238
BORDER="0"
 
239
BGCOLOR="#E0E0E0"
 
240
WIDTH="90%"
 
241
><TR
 
242
><TD
 
243
><PRE
 
244
CLASS="PROGRAMLISTING"
 
245
>   1&nbsp;#!/bin/bash
 
246
   2&nbsp;# date-calc.sh
 
247
   3&nbsp;# Author: Nathan Coulter
 
248
   4&nbsp;# Used in ABS Guide with permission (thanks!).
 
249
   5&nbsp;
 
250
   6&nbsp;MPHR=60    # Minutes per hour.
 
251
   7&nbsp;HPD=24     # Hours per day.
 
252
   8&nbsp;
 
253
   9&nbsp;diff () {
 
254
  10&nbsp;        printf '%s' $(( $(date -u -d"$TARGET" +%s) -
 
255
  11&nbsp;                        $(date -u -d"$CURRENT" +%s)))
 
256
  12&nbsp;#                       %d = day of month.
 
257
  13&nbsp;}
 
258
  14&nbsp;
 
259
  15&nbsp;
 
260
  16&nbsp;CURRENT=$(date -u -d '2007-09-01 17:30:24' '+%F %T.%N %Z')
 
261
  17&nbsp;TARGET=$(date -u -d'2007-12-25 12:30:00' '+%F %T.%N %Z')
 
262
  18&nbsp;# %F = full date, %T = %H:%M:%S, %N = nanoseconds, %Z = time zone.
 
263
  19&nbsp;
 
264
  20&nbsp;printf '\nIn 2007, %s ' \
 
265
  21&nbsp;       "$(date -d"$CURRENT +
 
266
  22&nbsp;        $(( $(diff) /$MPHR /$MPHR /$HPD / 2 )) days" '+%d %B')" 
 
267
  23&nbsp;#       %B = name of month                ^ halfway
 
268
  24&nbsp;printf 'was halfway between %s ' "$(date -d"$CURRENT" '+%d %B')"
 
269
  25&nbsp;printf 'and %s\n' "$(date -d"$TARGET" '+%d %B')"
 
270
  26&nbsp;
 
271
  27&nbsp;printf '\nOn %s at %s, there were\n' \
 
272
  28&nbsp;        $(date -u -d"$CURRENT" +%F) $(date -u -d"$CURRENT" +%T)
 
273
  29&nbsp;DAYS=$(( $(diff) / $MPHR / $MPHR / $HPD ))
 
274
  30&nbsp;CURRENT=$(date -d"$CURRENT +$DAYS days" '+%F %T.%N %Z')
 
275
  31&nbsp;HOURS=$(( $(diff) / $MPHR / $MPHR ))
 
276
  32&nbsp;CURRENT=$(date -d"$CURRENT +$HOURS hours" '+%F %T.%N %Z')
 
277
  33&nbsp;MINUTES=$(( $(diff) / $MPHR ))
 
278
  34&nbsp;CURRENT=$(date -d"$CURRENT +$MINUTES minutes" '+%F %T.%N %Z')
 
279
  35&nbsp;printf '%s days, %s hours, ' "$DAYS" "$HOURS"
 
280
  36&nbsp;printf '%s minutes, and %s seconds ' "$MINUTES" "$(diff)"
 
281
  37&nbsp;printf 'until Christmas Dinner!\n\n'
 
282
  38&nbsp;
 
283
  39&nbsp;#  Exercise:
 
284
  40&nbsp;#  --------
 
285
  41&nbsp;#  Rewrite the diff () function to accept passed parameters,
 
286
  42&nbsp;#+ rather than using global variables.</PRE
 
287
></TD
 
288
></TR
 
289
></TABLE
 
290
><HR></DIV
 
291
><P
 
292
><A
 
293
NAME="DATERANDREF"
 
294
></A
 
295
></P
 
296
><P
 
297
>The <I
 
298
CLASS="FIRSTTERM"
 
299
>date</I
 
300
> command has quite a
 
301
                number of <I
 
302
CLASS="FIRSTTERM"
 
303
>output</I
 
304
> options. For
 
305
                example <TT
 
306
CLASS="OPTION"
 
307
>%N</TT
 
308
> gives the nanosecond portion
 
309
                of the current time. One interesting use for this is to
 
310
                generate random integers.
 
311
 
 
312
               <TABLE
 
313
BORDER="0"
 
314
BGCOLOR="#E0E0E0"
 
315
WIDTH="90%"
 
316
><TR
 
317
><TD
 
318
><PRE
 
319
CLASS="PROGRAMLISTING"
 
320
>   1&nbsp;date +%N | sed -e 's/000$//' -e 's/^0//'
 
321
   2&nbsp;           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
322
   3&nbsp;#  Strip off leading and trailing zeroes, if present.
 
323
   4&nbsp;#  Length of generated integer depends on
 
324
   5&nbsp;#+ how many zeroes stripped off.
 
325
   6&nbsp;
 
326
   7&nbsp;# 115281032
 
327
   8&nbsp;# 63408725
 
328
   9&nbsp;# 394504284</PRE
 
329
></TD
 
330
></TR
 
331
></TABLE
 
332
>
 
333
              </P
 
334
><P
 
335
>There are many more options (try <B
 
336
CLASS="COMMAND"
 
337
>man
 
338
                date</B
 
339
>).</P
 
340
><P
 
341
><TABLE
 
342
BORDER="0"
 
343
BGCOLOR="#E0E0E0"
 
344
WIDTH="90%"
 
345
><TR
 
346
><TD
 
347
><PRE
 
348
CLASS="PROGRAMLISTING"
 
349
>   1&nbsp;date +%j
 
350
   2&nbsp;# Echoes day of the year (days elapsed since January 1).
 
351
   3&nbsp;
 
352
   4&nbsp;date +%k%M
 
353
   5&nbsp;# Echoes hour and minute in 24-hour format, as a single digit string.
 
354
   6&nbsp;
 
355
   7&nbsp;
 
356
   8&nbsp;
 
357
   9&nbsp;# The 'TZ' parameter permits overriding the default time zone.
 
358
  10&nbsp;date                 # Mon Mar 28 21:42:16 MST 2005
 
359
  11&nbsp;TZ=EST date          # Mon Mar 28 23:42:16 EST 2005
 
360
  12&nbsp;# Thanks, Frank Kannemann and Pete Sjoberg, for the tip.
 
361
  13&nbsp;
 
362
  14&nbsp;
 
363
  15&nbsp;SixDaysAgo=$(date --date='6 days ago')
 
364
  16&nbsp;OneMonthAgo=$(date --date='1 month ago')  # Four weeks back (not a month!)
 
365
  17&nbsp;OneYearAgo=$(date --date='1 year ago')</PRE
 
366
></TD
 
367
></TR
 
368
></TABLE
 
369
></P
 
370
><P
 
371
>See also <A
 
372
HREF="special-chars.html#EX58"
 
373
>Example 3-4</A
 
374
> and <A
 
375
HREF="contributed-scripts.html#STOPWATCH"
 
376
>Example A-43</A
 
377
>.</P
 
378
></DD
 
379
><DT
 
380
><A
 
381
NAME="ZDUMPREF"
 
382
></A
 
383
><B
 
384
CLASS="COMMAND"
 
385
>zdump</B
 
386
></DT
 
387
><DD
 
388
><P
 
389
>Time zone dump: echoes the time in a specified time zone.</P
 
390
><P
 
391
>             <TABLE
 
392
BORDER="0"
 
393
BGCOLOR="#E0E0E0"
 
394
WIDTH="90%"
 
395
><TR
 
396
><TD
 
397
><PRE
 
398
CLASS="SCREEN"
 
399
> <TT
 
400
CLASS="PROMPT"
 
401
>bash$ </TT
 
402
><TT
 
403
CLASS="USERINPUT"
 
404
><B
 
405
>zdump EST</B
 
406
></TT
 
407
>
 
408
 <TT
 
409
CLASS="COMPUTEROUTPUT"
 
410
>EST  Tue Sep 18 22:09:22 2001 EST</TT
 
411
>
 
412
              </PRE
 
413
></TD
 
414
></TR
 
415
></TABLE
 
416
>
 
417
              </P
 
418
></DD
 
419
><DT
 
420
><A
 
421
NAME="TIMREF"
 
422
></A
 
423
><B
 
424
CLASS="COMMAND"
 
425
>time</B
 
426
></DT
 
427
><DD
 
428
><P
 
429
>Outputs verbose timing statistics for executing a command.</P
 
430
><P
 
431
><TT
 
432
CLASS="USERINPUT"
 
433
><B
 
434
>time ls -l /</B
 
435
></TT
 
436
> gives something
 
437
            like this:</P
 
438
><P
 
439
><TABLE
 
440
BORDER="0"
 
441
BGCOLOR="#E0E0E0"
 
442
WIDTH="90%"
 
443
><TR
 
444
><TD
 
445
><PRE
 
446
CLASS="SCREEN"
 
447
> <TT
 
448
CLASS="COMPUTEROUTPUT"
 
449
>real    0m0.067s
 
450
 user    0m0.004s
 
451
 sys     0m0.005s</TT
 
452
></PRE
 
453
></TD
 
454
></TR
 
455
></TABLE
 
456
>
 
457
          </P
 
458
><P
 
459
>See also the very similar <A
 
460
HREF="internal.html#TIMESREF"
 
461
>times</A
 
462
> command in the previous
 
463
            section.</P
 
464
><DIV
 
465
CLASS="NOTE"
 
466
><TABLE
 
467
CLASS="NOTE"
 
468
WIDTH="90%"
 
469
BORDER="0"
 
470
><TR
 
471
><TD
 
472
WIDTH="25"
 
473
ALIGN="CENTER"
 
474
VALIGN="TOP"
 
475
><IMG
 
476
SRC="common/note.png"
 
477
HSPACE="5"
 
478
ALT="Note"></TD
 
479
><TD
 
480
ALIGN="LEFT"
 
481
VALIGN="TOP"
 
482
><P
 
483
>As of <A
 
484
HREF="bash2.html#BASH2REF"
 
485
>version 2.0</A
 
486
>
 
487
            of Bash, <B
 
488
CLASS="COMMAND"
 
489
>time</B
 
490
> became a shell reserved word,
 
491
            with slightly altered behavior in a pipeline.</P
 
492
></TD
 
493
></TR
 
494
></TABLE
 
495
></DIV
 
496
></DD
 
497
><DT
 
498
><A
 
499
NAME="TOUCHREF"
 
500
></A
 
501
><B
 
502
CLASS="COMMAND"
 
503
>touch</B
 
504
></DT
 
505
><DD
 
506
><P
 
507
>Utility for updating access/modification times of a
 
508
              file to current system time or other specified time,
 
509
              but also useful for creating a new file. The command
 
510
              <TT
 
511
CLASS="USERINPUT"
 
512
><B
 
513
>touch zzz</B
 
514
></TT
 
515
> will create a new file
 
516
              of zero length, named <TT
 
517
CLASS="FILENAME"
 
518
>zzz</TT
 
519
>, assuming
 
520
              that <TT
 
521
CLASS="FILENAME"
 
522
>zzz</TT
 
523
> did not previously exist.
 
524
              Time-stamping empty files in this way is useful for
 
525
              storing date information, for example in keeping track of
 
526
              modification times on a project.
 
527
              </P
 
528
><DIV
 
529
CLASS="NOTE"
 
530
><TABLE
 
531
CLASS="NOTE"
 
532
WIDTH="90%"
 
533
BORDER="0"
 
534
><TR
 
535
><TD
 
536
WIDTH="25"
 
537
ALIGN="CENTER"
 
538
VALIGN="TOP"
 
539
><IMG
 
540
SRC="common/note.png"
 
541
HSPACE="5"
 
542
ALT="Note"></TD
 
543
><TD
 
544
ALIGN="LEFT"
 
545
VALIGN="TOP"
 
546
><P
 
547
>The <B
 
548
CLASS="COMMAND"
 
549
>touch</B
 
550
> command is
 
551
              equivalent to <TT
 
552
CLASS="USERINPUT"
 
553
><B
 
554
>: &#62;&#62; newfile</B
 
555
></TT
 
556
>
 
557
              or <TT
 
558
CLASS="USERINPUT"
 
559
><B
 
560
>&#62;&#62; newfile</B
 
561
></TT
 
562
> (for ordinary
 
563
              files).</P
 
564
></TD
 
565
></TR
 
566
></TABLE
 
567
></DIV
 
568
><DIV
 
569
CLASS="TIP"
 
570
><TABLE
 
571
CLASS="TIP"
 
572
WIDTH="90%"
 
573
BORDER="0"
 
574
><TR
 
575
><TD
 
576
WIDTH="25"
 
577
ALIGN="CENTER"
 
578
VALIGN="TOP"
 
579
><IMG
 
580
SRC="common/tip.png"
 
581
HSPACE="5"
 
582
ALT="Tip"></TD
 
583
><TD
 
584
ALIGN="LEFT"
 
585
VALIGN="TOP"
 
586
><P
 
587
>Before doing a <A
 
588
HREF="external.html#CPREF"
 
589
>cp -u</A
 
590
>
 
591
              (<I
 
592
CLASS="FIRSTTERM"
 
593
>copy/update</I
 
594
>), use
 
595
              <B
 
596
CLASS="COMMAND"
 
597
>touch</B
 
598
> to update the time stamp of files
 
599
              you don't wish overwritten.</P
 
600
><P
 
601
>As an example, if the directory <TT
 
602
CLASS="FILENAME"
 
603
>/home/bozo/tax_audit</TT
 
604
> contains the
 
605
              files <TT
 
606
CLASS="FILENAME"
 
607
>spreadsheet-051606.data</TT
 
608
>,
 
609
              <TT
 
610
CLASS="FILENAME"
 
611
>spreadsheet-051706.data</TT
 
612
>, and
 
613
              <TT
 
614
CLASS="FILENAME"
 
615
>spreadsheet-051806.data</TT
 
616
>, then
 
617
              doing a <B
 
618
CLASS="COMMAND"
 
619
>touch spreadsheet*.data</B
 
620
>
 
621
              will protect these files from being overwritten
 
622
              by files with the same names during a
 
623
              <B
 
624
CLASS="COMMAND"
 
625
>cp -u /home/bozo/financial_info/spreadsheet*data
 
626
              /home/bozo/tax_audit</B
 
627
>.</P
 
628
></TD
 
629
></TR
 
630
></TABLE
 
631
></DIV
 
632
></DD
 
633
><DT
 
634
><A
 
635
NAME="ATREF"
 
636
></A
 
637
><B
 
638
CLASS="COMMAND"
 
639
>at</B
 
640
></DT
 
641
><DD
 
642
><P
 
643
>The <B
 
644
CLASS="COMMAND"
 
645
>at</B
 
646
> job control command executes
 
647
              a given set of commands at a specified time. Superficially,
 
648
              it resembles <A
 
649
HREF="system.html#CRONREF"
 
650
>cron</A
 
651
>, however,
 
652
              <B
 
653
CLASS="COMMAND"
 
654
>at</B
 
655
> is chiefly useful for one-time execution
 
656
              of a command set.</P
 
657
><P
 
658
><TT
 
659
CLASS="USERINPUT"
 
660
><B
 
661
>at 2pm January 15</B
 
662
></TT
 
663
> prompts for a set of
 
664
              commands to execute at that time. These commands should be
 
665
              shell-script compatible, since, for all practical
 
666
              purposes, the user is typing in an executable shell
 
667
              script a line at a time.  Input terminates with a <A
 
668
HREF="special-chars.html#CTLDREF"
 
669
>Ctl-D</A
 
670
>.</P
 
671
><P
 
672
>Using either the <TT
 
673
CLASS="OPTION"
 
674
>-f</TT
 
675
> option or input
 
676
              redirection (<SPAN
 
677
CLASS="TOKEN"
 
678
>&#60;</SPAN
 
679
>), <B
 
680
CLASS="COMMAND"
 
681
>at</B
 
682
>
 
683
              reads a command list from a file. This file is an
 
684
              executable shell script, though it should, of course,
 
685
              be non-interactive. Particularly clever is including the
 
686
              <A
 
687
HREF="extmisc.html#RUNPARTSREF"
 
688
>run-parts</A
 
689
> command in
 
690
              the file to execute a different set of scripts.</P
 
691
><P
 
692
>             <TABLE
 
693
BORDER="0"
 
694
BGCOLOR="#E0E0E0"
 
695
WIDTH="90%"
 
696
><TR
 
697
><TD
 
698
><PRE
 
699
CLASS="SCREEN"
 
700
> <TT
 
701
CLASS="PROMPT"
 
702
>bash$ </TT
 
703
><TT
 
704
CLASS="USERINPUT"
 
705
><B
 
706
>at 2:30 am Friday &#60; at-jobs.list</B
 
707
></TT
 
708
>
 
709
 <TT
 
710
CLASS="COMPUTEROUTPUT"
 
711
>job 2 at 2000-10-27 02:30</TT
 
712
>
 
713
              </PRE
 
714
></TD
 
715
></TR
 
716
></TABLE
 
717
>
 
718
            </P
 
719
></DD
 
720
><DT
 
721
><A
 
722
NAME="BATCHREF"
 
723
></A
 
724
><B
 
725
CLASS="COMMAND"
 
726
>batch</B
 
727
></DT
 
728
><DD
 
729
><P
 
730
>The <B
 
731
CLASS="COMMAND"
 
732
>batch</B
 
733
> job control command is similar to
 
734
              <B
 
735
CLASS="COMMAND"
 
736
>at</B
 
737
>, but it runs a command list when the system
 
738
              load drops below <TT
 
739
CLASS="LITERAL"
 
740
>.8</TT
 
741
>. Like
 
742
              <B
 
743
CLASS="COMMAND"
 
744
>at</B
 
745
>, it can read commands from a file with the
 
746
              <TT
 
747
CLASS="OPTION"
 
748
>-f</TT
 
749
> option.</P
 
750
><P
 
751
><A
 
752
NAME="BATCHPROCREF"
 
753
></A
 
754
></P
 
755
><TABLE
 
756
CLASS="SIDEBAR"
 
757
BORDER="1"
 
758
CELLPADDING="5"
 
759
><TR
 
760
><TD
 
761
><DIV
 
762
CLASS="SIDEBAR"
 
763
><A
 
764
NAME="AEN10747"
 
765
></A
 
766
><P
 
767
>The concept of <I
 
768
CLASS="FIRSTTERM"
 
769
>batch processing</I
 
770
>
 
771
              dates back to the era of mainframe computers. It means
 
772
              running a set of commands without user intervention.</P
 
773
></DIV
 
774
></TD
 
775
></TR
 
776
></TABLE
 
777
></DD
 
778
><DT
 
779
><A
 
780
NAME="CALREF"
 
781
></A
 
782
><B
 
783
CLASS="COMMAND"
 
784
>cal</B
 
785
></DT
 
786
><DD
 
787
><P
 
788
>Prints a neatly formatted monthly calendar to
 
789
              <TT
 
790
CLASS="FILENAME"
 
791
>stdout</TT
 
792
>. Will do current year or a large
 
793
              range of past and future years.</P
 
794
></DD
 
795
><DT
 
796
><A
 
797
NAME="SLEEPREF"
 
798
></A
 
799
><B
 
800
CLASS="COMMAND"
 
801
>sleep</B
 
802
></DT
 
803
><DD
 
804
><P
 
805
>This is the shell equivalent of a <I
 
806
CLASS="FIRSTTERM"
 
807
>wait
 
808
              loop</I
 
809
>. It pauses for a specified number of
 
810
              seconds, doing nothing. It can be useful for timing or
 
811
              in processes running in the background, checking for
 
812
              a specific event every so often (polling), as in <A
 
813
HREF="debugging.html#ONLINE"
 
814
>Example 32-6</A
 
815
>.  <TABLE
 
816
BORDER="0"
 
817
BGCOLOR="#E0E0E0"
 
818
WIDTH="90%"
 
819
><TR
 
820
><TD
 
821
><PRE
 
822
CLASS="PROGRAMLISTING"
 
823
>   1&nbsp;sleep 3     # Pauses 3 seconds.</PRE
 
824
></TD
 
825
></TR
 
826
></TABLE
 
827
>
 
828
            </P
 
829
><DIV
 
830
CLASS="NOTE"
 
831
><TABLE
 
832
CLASS="NOTE"
 
833
WIDTH="90%"
 
834
BORDER="0"
 
835
><TR
 
836
><TD
 
837
WIDTH="25"
 
838
ALIGN="CENTER"
 
839
VALIGN="TOP"
 
840
><IMG
 
841
SRC="common/note.png"
 
842
HSPACE="5"
 
843
ALT="Note"></TD
 
844
><TD
 
845
ALIGN="LEFT"
 
846
VALIGN="TOP"
 
847
><P
 
848
>The <B
 
849
CLASS="COMMAND"
 
850
>sleep</B
 
851
> command defaults to
 
852
              seconds, but minute, hours, or days may also be specified.
 
853
              <TABLE
 
854
BORDER="0"
 
855
BGCOLOR="#E0E0E0"
 
856
WIDTH="90%"
 
857
><TR
 
858
><TD
 
859
><PRE
 
860
CLASS="PROGRAMLISTING"
 
861
>   1&nbsp;sleep 3 h   # Pauses 3 hours!</PRE
 
862
></TD
 
863
></TR
 
864
></TABLE
 
865
>
 
866
            </P
 
867
></TD
 
868
></TR
 
869
></TABLE
 
870
></DIV
 
871
><DIV
 
872
CLASS="NOTE"
 
873
><TABLE
 
874
CLASS="NOTE"
 
875
WIDTH="90%"
 
876
BORDER="0"
 
877
><TR
 
878
><TD
 
879
WIDTH="25"
 
880
ALIGN="CENTER"
 
881
VALIGN="TOP"
 
882
><IMG
 
883
SRC="common/note.png"
 
884
HSPACE="5"
 
885
ALT="Note"></TD
 
886
><TD
 
887
ALIGN="LEFT"
 
888
VALIGN="TOP"
 
889
><P
 
890
>The <A
 
891
HREF="system.html#WATCHREF"
 
892
>watch</A
 
893
> command may
 
894
              be a better choice than <B
 
895
CLASS="COMMAND"
 
896
>sleep</B
 
897
> for running
 
898
              commands at timed intervals.</P
 
899
></TD
 
900
></TR
 
901
></TABLE
 
902
></DIV
 
903
></DD
 
904
><DT
 
905
><A
 
906
NAME="USLEEPREF"
 
907
></A
 
908
><B
 
909
CLASS="COMMAND"
 
910
>usleep</B
 
911
></DT
 
912
><DD
 
913
><P
 
914
><I
 
915
CLASS="FIRSTTERM"
 
916
>Microsleep</I
 
917
> (the
 
918
              <I
 
919
CLASS="FIRSTTERM"
 
920
>u</I
 
921
> may be read as the Greek
 
922
              <I
 
923
CLASS="FIRSTTERM"
 
924
>mu</I
 
925
>, or <I
 
926
CLASS="FIRSTTERM"
 
927
>micro-</I
 
928
>
 
929
              prefix). This is the same as <B
 
930
CLASS="COMMAND"
 
931
>sleep</B
 
932
>,
 
933
              above, but <SPAN
 
934
CLASS="QUOTE"
 
935
>"sleeps"</SPAN
 
936
> in microsecond
 
937
              intervals. It can be used for fine-grained timing,
 
938
              or for polling an ongoing process at very frequent
 
939
              intervals.</P
 
940
><P
 
941
>  
 
942
              <TABLE
 
943
BORDER="0"
 
944
BGCOLOR="#E0E0E0"
 
945
WIDTH="90%"
 
946
><TR
 
947
><TD
 
948
><PRE
 
949
CLASS="PROGRAMLISTING"
 
950
>   1&nbsp;usleep 30     # Pauses 30 microseconds.</PRE
 
951
></TD
 
952
></TR
 
953
></TABLE
 
954
>
 
955
            </P
 
956
><P
 
957
>This command is part of the Red Hat
 
958
            <I
 
959
CLASS="FIRSTTERM"
 
960
>initscripts / rc-scripts</I
 
961
> package.</P
 
962
><DIV
 
963
CLASS="CAUTION"
 
964
><TABLE
 
965
CLASS="CAUTION"
 
966
WIDTH="90%"
 
967
BORDER="0"
 
968
><TR
 
969
><TD
 
970
WIDTH="25"
 
971
ALIGN="CENTER"
 
972
VALIGN="TOP"
 
973
><IMG
 
974
SRC="common/caution.png"
 
975
HSPACE="5"
 
976
ALT="Caution"></TD
 
977
><TD
 
978
ALIGN="LEFT"
 
979
VALIGN="TOP"
 
980
><P
 
981
>The <B
 
982
CLASS="COMMAND"
 
983
>usleep</B
 
984
> command does not
 
985
              provide particularly accurate timing, and is therefore
 
986
              unsuitable for critical timing loops.</P
 
987
></TD
 
988
></TR
 
989
></TABLE
 
990
></DIV
 
991
></DD
 
992
><DT
 
993
><A
 
994
NAME="HWCLOCKREF"
 
995
></A
 
996
><B
 
997
CLASS="COMMAND"
 
998
>hwclock</B
 
999
>, <A
 
1000
NAME="CLOCKREF"
 
1001
></A
 
1002
><B
 
1003
CLASS="COMMAND"
 
1004
>clock</B
 
1005
></DT
 
1006
><DD
 
1007
><P
 
1008
>The <B
 
1009
CLASS="COMMAND"
 
1010
>hwclock</B
 
1011
> command accesses or
 
1012
              adjusts the machine's hardware clock. Some options
 
1013
              require <I
 
1014
CLASS="FIRSTTERM"
 
1015
>root</I
 
1016
> privileges. The
 
1017
              <TT
 
1018
CLASS="FILENAME"
 
1019
>/etc/rc.d/rc.sysinit</TT
 
1020
> startup file
 
1021
              uses <B
 
1022
CLASS="COMMAND"
 
1023
>hwclock</B
 
1024
> to set the system time
 
1025
              from the hardware clock at bootup.</P
 
1026
><P
 
1027
>The <B
 
1028
CLASS="COMMAND"
 
1029
>clock</B
 
1030
> command is a synonym for
 
1031
              <B
 
1032
CLASS="COMMAND"
 
1033
>hwclock</B
 
1034
>.</P
 
1035
></DD
 
1036
></DL
 
1037
></DIV
 
1038
></DIV
 
1039
><DIV
 
1040
CLASS="NAVFOOTER"
 
1041
><HR
 
1042
ALIGN="LEFT"
 
1043
WIDTH="100%"><TABLE
 
1044
SUMMARY="Footer navigation table"
 
1045
WIDTH="100%"
 
1046
BORDER="0"
 
1047
CELLPADDING="0"
 
1048
CELLSPACING="0"
 
1049
><TR
 
1050
><TD
 
1051
WIDTH="33%"
 
1052
ALIGN="left"
 
1053
VALIGN="top"
 
1054
><A
 
1055
HREF="moreadv.html"
 
1056
ACCESSKEY="P"
 
1057
>Prev</A
 
1058
></TD
 
1059
><TD
 
1060
WIDTH="34%"
 
1061
ALIGN="center"
 
1062
VALIGN="top"
 
1063
><A
 
1064
HREF="index.html"
 
1065
ACCESSKEY="H"
 
1066
>Home</A
 
1067
></TD
 
1068
><TD
 
1069
WIDTH="33%"
 
1070
ALIGN="right"
 
1071
VALIGN="top"
 
1072
><A
 
1073
HREF="textproc.html"
 
1074
ACCESSKEY="N"
 
1075
>Next</A
 
1076
></TD
 
1077
></TR
 
1078
><TR
 
1079
><TD
 
1080
WIDTH="33%"
 
1081
ALIGN="left"
 
1082
VALIGN="top"
 
1083
>Complex Commands</TD
 
1084
><TD
 
1085
WIDTH="34%"
 
1086
ALIGN="center"
 
1087
VALIGN="top"
 
1088
><A
 
1089
HREF="external.html"
 
1090
ACCESSKEY="U"
 
1091
>Up</A
 
1092
></TD
 
1093
><TD
 
1094
WIDTH="33%"
 
1095
ALIGN="right"
 
1096
VALIGN="top"
 
1097
>Text Processing Commands</TD
 
1098
></TR
 
1099
></TABLE
 
1100
></DIV
 
1101
></BODY
 
1102
></HTML
 
1103
>
 
 
b'\\ No newline at end of file'