
Use the -t option to tag a line, followed by the tag. Now, you might find it difficult to see only the pertinent lines to your script. Jun 3 00:51:17 - last message repeated 1 time. This helps to keep log files a bit more trim than they otherwise might be if you have, say, 10,000 lines with the same content: You will also note that consecutive rows with the same information simply say - last message repeated 1 time. But if you go back and add a second line of data into your log file, and re-run the logger command against that file you’ll notice that the pid is included with each line the same no matter whether you use the -i or not, making the -i unnecessary. The -i option is used to include the pid for the logger process in each line. Or you can write directly into the log as needed.

Using that structure, you can write data into a file and then later dump that data into the log, so as not to fill up the system.log file with tons of random data as it happens. You will then see something like the following, with your mylogdata string in it: Now that we have a file, use the -f option to include the contents of the file into the system.log, specifying the path to the file: This is meant to emulate having written some data into a log file. Next, we’ll create a text file called froggerlog in our home directory, populating it with just the string: mylogdata. If you run ps you’ll note that the pid is no longer in use. The pid is the process id of the logger command you just ran. You’ll then see the same line, with the pid more than likely incremented up by one. Now that you’ve done that, go ahead and press the up arrow on your keyboard to see the line again and then hit enter. Jun 3 00:34:44 ce. krypted: froggerĬongrats, you’ve successfully written your own log entry into the system log. This will show you an entry similar to the following:

In the other window, we’re going to simply enter the logger command followed by the word frogger: In one window, we’re going to look at the output of the system.log file interactively using the tail command with the -f option To show how this command works, we’re going to open two terminal windows, preferably side-by-side. The logger command allows you to “make entries in the system log.” When using the logger command, you can write to your own entries to the system log. When bash scripting, a useful command is logger.
