At—At, Batch—Execute Commands at a Later Time

At—At, Batch—Execute Commands at a Later Time

at—at, batch—execute commands at a later time at [–csm] [–f script] [–qqueue] time [date] [+ increment] at –l [ job...] at –r job... batch at and batch read commands from standard input to be executed at a later time. at allows you to specify when the commands should be executed, while jobs queued with batch will execute when system load level permits. Executes commands read from stdin or a file at some later time. Unless redirected, the output is mailed to the user. Example A.1 1 at 6:30am Dec 12 < program 2 at noon tomorrow < program 3 at 1945 pm August 9 < program 4 at now + 3 hours < program 5 at 8:30am Jan 4 < program 6 at -r 83883555320.a EXPLANATION 1. At 6:30 in the morning on December 12th, start the job. 2. At noon tomorrow start the job. 3. At 7:45 in the evening on August 9th, start the job. 4. In three hours start the job. 5. At 8:30 in the morning of January 4th, start the job. 6. Removes previously scheduled job 83883555320.a. awk—pattern scanning and processing language awk [ –fprogram–file ] [ –Fc ] [ prog ] [ parameters ] [ filename...] awk scans each input filename for lines that match any of a set of patterns specified in prog. Example A.2 1 awk '{print $1, $2}' file 2 awk '/John/{print $3, $4}' file 3 awk -F: '{print $3}' /etc/passwd 4 date | awk '{print $6}' EXPLANATION 1. Prints the first two fields of file where fields are separated by whitespace. 2. Prints fields 3 and 4 if the pattern John is found. 3. Using a colon as the field separator, prints the third field of the /etc/passwd file. 4. Sends the output of the date command to awk and prints the sixth field. banner—make posters banner prints its arguments (each up to 10 characters long) in large letters on the standard output. Example A.3 banner Happy Birthday EXPLANATION Displays in banner format the string Happy Birthday. basename—with a directory name delivers portions of the pathname basename string [ suffix ] dirname string basename deletes any prefix ending in / (forward slash) and the suffix (if present in string) from string, and prints the result on the standard output. Example A.4 1 basename /usr/local/bin 2 scriptname="'basename $0'" EXPLANATION 1. Strips off the prefix /usr/local/ and displays bin. 2. Assigns just the name of the script, $0, to the variable scriptname bc—processes precision arithmetic bc [ –c ] [ –l ] [ filename...] bc is an interactive processor for a language that resembles C but provides unlimited precision arithmetic. It takes input from any files given, then reads the standard input. Example A.5 1 bc << EOF scale=3 4.5 + 5.6 / 3 EOF Output : 6.366 ----------------------------- 2 bc ibase=2 5 101 (Output) 20 10100 (Output ^D EXPLANATION 1. This is a here document. From the first EOF to the last EOF input is given to the bc command. The scale specifies the number of digits to the right of the decimal point. The result of the calculation is displayed on the screen. 2. The number base is two. The number is converted to binary (AT&T only). bdiff—compares two big files bdiff compares two files that are too large for diff. cal—displays a calendar cal [ [ month ] year ] cal prints a calendar for the specified year. If a month is also specified, a calendar just for that month is printed. If neither is specified, a calendar for the present month is printed. Example A.6 1 cal 1997 2 cal 5 1978 EXPLANATION 1. Prints the calendar year 1997. 2. Prints the month of May for 1978. cat—concatenates and displays files cat [ –bnsuvet ] filename... cat reads each filename in sequence and writes it on the standard output. If no input file is given, or if the argument – is encountered, cat reads from the standard input file. Example A.7 1 cat /etc/passwd 2 cat -n file1 file2 >> file3 EXPLANATION 1. Displays the contents of the /etc/passwd file. 2. Concatenates file1 and file2 and appends output to file3. The –n switch causes each line to be numbered. chmod—change the permissions mode of a file chmod [ –fR ] mode filename... chmod [ugoa ]{ + | – | = }[ rwxlsStTugo] filename... chmod changes or assigns the mode of a file. The mode of a file specifies its permissions and other attributes. The mode may be absolute or symbolic. Example A.8 1 chmod +x script.file 2 chmod u+x,g-x file 3 chmod 755 * EXPLANATION 1. Turns on execute permission for user, group, and others on script.file. 2. Turns on execute permission for user, and removes it from group on file. 3. Turns on read, write, and execute for the user, read and execute for the group, and read and execute for others on all files in the current working directory. The value is octal ( 111 101 101 ). 4. rwxxr-xr-x chown—changes owner of file chown [ –fhR ] owner filename ... chown changes the owner of the files to owner. The owner may be either a decimal user ID or a login name found in /etc/passwd file. Only the owner of a file (or the superuser) may change the owner of that file. Example A.9 1 chown john filex 2 chown -R ellie ellie EXPLANATION 1. Changes the user ID of filex to john. 2. Recursively changes the ownership to ellie for all files in ellie directory. clear—clears the terminal screen cmp—compares two files cmp [ –l ] [ –s ] filename1 filename2 The two files are compared. cmp makes no comment if the files are the same; if they differ, it announces the byte and line numbers at which the first difference occurred. Example A.10 cmp file.new file.old EXPLANATION If the files differ, the character number and the line number are displayed. compress—compress, uncompress, zcat compress, uncompress files, or display expanded files compress [ –cfv ] [ –b bits ] [ filename... ] uncompress [ –cv ] [ filename... ] zcat [ filename... ] compress reduces the size of the named files using adaptive Lempel-Ziv coding. Whenever possible, each file is replaced by one with a .Z extension. The ownership modes, access time, and modification time will stay the same. If no files are specified, the standard input is compressed to the standard output. Example A.11 1 compress -v book book:Compression:35.07% -- replaced with book.Z 2 ls book.Z EXPLANATION 1. Compresses the book into a file called book.Z and displays the percentage that the file was compressed and its new name. cp—copies files cp [ –i ] [ –p ] [ –r ] [ filename ... ] target The cp command copies filename to another target, which is either a file or directory. The filename and target cannot have the same name. If the target is not a directory, only one file may be specified before it; if it is a directory, more than one file may be specified. If target does not exist, cp creates a file named target. If target exists and is not a directory, its contents are overwritten. If target is a directory, the file(s) are copied to that directory. Example A.12 1 cp file1 file2 2 cp chapter1 book 3 cp -r desktop /usr/bin/tester EXPLANATION 1. Copies the contents of file1 to file2. 2. Copies the contents of chapter1 to the book directory. In the book directory, chapter1 has its original name. 3. Recursively copies the entire desktop directory into /usr/bin/tester. cpio—copy file archives in and out cpio –i [ bBcdfkmrsStuvV6 ] [ –C bufsize ] [ –E filename ] [ –H header ] [ –I filename [ –M message ] ] [ –R id ] [ pattern ... ] cpio –o [ aABcLvV ] [ –C bufsize ] [ –H header ] [ –O filename [ –M message ] ] cpio –p [ adlLmuvV ] [ –R id ] directory Copies file archives according to the modifiers given, usually for backup to a tape or directory. Example A.13 find . -depth -print | cpio -pdmv /home/john/tmp EXPLANATION Starting at the current directory, find descends the directory hierarchy, printing each entries of the directory even if the directory does not have write permission, and sends the filenames to cpio to be copied into the john/tmp directory in the /home partition. cron—the clock daemon cron executes commands at specified dates and times. Regularly scheduled jobs can be specified in the /etc/crontab file. In order to use cron, one of the following must be true: (1) you are superuser; (2) you are regular user, but your user ID is listed in the /etc/cron.allow file; (3) you are regular user, but your system contains a file /etc/cron.deny, which is empty. crypt—encodes or decodes a file crypt [ password ] crypt encrypts and decrypts the contents of a file. The password is a key that selects a type of transformation. cut—removes selected fields or characters from each line of a file cut –clist [ filename ... ] cut –flist [ –dc ] [ –s ] [ filename ... ] The cut command cuts out columns or characters from a line of a file; if no files are given, uses standard input. The –d option specifies the field delimiter. The default delimiter is a tab. Example A.14 1 cut -d: -f1,3 /etc/passwd 2 cut -d: -f1-5 /etc/passwd 3 cut -c1-3,8-12 /etc/passwd 4 date | cut -c1-3 EXPLANATION 1. Using the colon as a field delimiter, displays fields 1 and 3 of the /etc/passwd file. 2. Using the colon as a field separator, displays fields 1 through 5 of the etc/passwd file. 3. Cuts and displays characters 1 through 3 and 8 through 12 of each line from the /etc/passwd file.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    114 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us