If you administer a Linux machine it is quite likely that you see a lot of messages fly by on your screen as you run commands. Ja ievadāt Linux mašīna ir diezgan iespējams, ka jūs redzat daudz ziņu lidot uz ekrāna, kā jūs izmantojat komandas. Some of these messages are trivial, while others may be critical. Daži no šiem ziņojumiem ir niecīgs, savukārt citi var būt izšķirīga nozīme. Although Linux and UNIX have a fine logging engine in syslogd and most of the system's messages are logged in a proper log format in various files under he /var/log directory, you might find it useful sometimes to log the output of a command or script that you have run. Kaut gan Linux un Unix soda meža motoru syslogd un lielākā daļa no sistēmas ziņojumi ir iegājis pareizi log formāts dažādu failu zem viņš / var / log direktorijā, jūs varētu atrast noderīgu dažreiz ieiet izejas komandu vai skriptu ka jums ir palaist. Linux provides a number of ways to log the output of your commands. Linux nodrošina vairākus veidus, lai pieteiktos produkciju jūsu komandas.
The simplest, and probably the most common way to do this is to put a greater than sign after a command, followed by the location of the output file. Vienkāršākais un, iespējams, visizplatītākais veids, kā to izdarīt, ir likt lielāku par zīmi pēc komandas, pēc atrašanās vietas izejas failu.
# ls /var/log > /tmp/varlog.log # Ls / var / log> / tmp / varlog.log
The command shown above logs the output of the command ls /var/log into the file /tmp/varlog.log . Komanda norādīts iepriekš apaļkokiem izejas komanda ls / var / log stājas failu / tmp / varlog.log. One thing to note about this command is that if you use a single greater than sign to log the output the output of a command to a file it will create a new file if not already present, or wipe clean, if one is found. Viena lieta ir piezīme par šī komanda ir tā, ka, ja jūs izmantojat vienu lielāks nekā apzīmējumu log produkcijas izlaidi komandu failu, tas radīs jaunu failu, ja nav jau klāt, vai noslaukiet tīru, ja tāds ir atrasts. So, if you want to append the output of the command to a file you need to use two greater than signs instead of one. Tātad, ja jūs vēlaties pievienot izejas komandu failu, jums ir nepieciešams izmantot divas lielāka nekā apzīmējumus, nevis viens. The command shown above needs to be modified to look like this: Komanda norādīts iepriekš, ir jāpārveido, lai izskatās šādi:
# ls /var/log >> /tmp/varlog.log # Ls / var / log>> / tmp / varlog.log
Linux has a tool aptly named logsave which does a similar task as greater than sign. Linux ir instruments trāpīgi nosaukts logsave, kas nav līdzīgs uzdevums, jo lielāka zīme. You can attain the same result as the first example using the following command: Jūs varat sasniegt tādu pašu rezultātu kā pirmajā piemērā, izmantojot komandu:
# logsave /tmp/varlog.log ls /var/log # Logsave / tmp / varlog.log ls / var / log
This command will create a new or overwrite an existing one with the output of the command ls /var/log . Šī komanda izveidos jaunu vai pārrakstīt esošo, ar rezultātu komandu ls / var / log. If you want logsave to append the out to a file instead of writing over it, using it with the -a option: Ja jūs vēlaties logsave to pievienot, lai fails, nevis rakstiski, nekā tam, izmantojot to ar-iespēju:
# logsave -a /tmp/varlog.log ls /var/log # Logsave-/ tmp / varlog.log ls / var / log
There isn't much of a difference between the greater than and the logsave method. Nav liela atšķirība starp lielāks un logsave metodi. The one thing I noticed was that logsave has a much cleaner output and it also adds the date to the output file. Viena lieta, ko es pamanīju bija tas, ka logsave ir daudz tīrākas ražošanas un tas arī piebilst dienas izejas failu.























{ 1 trackback } (1 Trackback)
{ 3 comments… read them below or (3 comments ... lasīt tos zem vai add one pievienot vienu } )
The one thing I noticed was that logsave has a much cleaner output Viena lieta, ko es pamanīju bija tas, ka logsave ir daudz tīrākas ražošanas
and what do you mean by that? un ko tu ar to domā? output is output, so either logsave is dismissing parts of the output or it should be the same? produkcija ir, tik nu logsave ir noraidot daļu no produkcijas vai tas būtu pats?
By cleaner output I mean that the output is organized in a better fashion using whitespace and new lines. Ar tīrākas ražošanas es domāju, ka produkcija ir organizēta labāk veidā, izmantojot atstarpes un jaunu līniju. And the fact that logsave marks the beginning and end of a session of output makes it a lot easier to return to the log file to debug at a later time. Un tas, ka logsave iezīmē sākumu un beigām sesijas produkcija ļauj daudz vieglāk atgriezties log failu atkļūdošanas uz vēlāku laiku.
Yes true I agree with Sukrit Jā taisnība, es piekrītu Sukrit
Leave a Comment Leave Comment