11/27/2023 0 Comments Ps efgrep commandUsing “du” with the “-ks” flags solves the problem. This is not always useful, since disk blocks are typically 512 bytes, and I am also interested in the files in this directory, as well as the directories below it. If I type “du” from a directory, I will get a listing of all directories under it, and how much space they take in disk blocks. While the “df” command shows me how full a file system is, the “du” utility lets me track down disk space usage by directory. Well, it is, but since this is Unix, it’s available from the command line. I hear many Unix users complain that such functionality is not available in Unix. Many Windows users are used to right clicking on a folder and seeing how much space that folder takes. If your OS does not come with pgrep, do some Googling, it may be available as open source. By using pgrep, we only start one command, and since it’s not getting all the data that “ps -ef” does, it uses a lot less resources. See the man page for pgrep on your flavor of Unix to see how it works. Note that all we get is the PID, which is usually all we are after. So to search for the process name we use the “-f” flag on pgrep (under Linux) to find our “pmon” process: $ pgrep -f pmon It’s possible for a program on Unix to change the process name that is displayed to something other than the executable name, and that is exactly what the Oracle background processes do. By default “pgrep” searches for the executable name, not the process name. Now, one thing to keep in mind is that all Oracle background processes (pmon, smon, dbwr, lgwr) are all the same executable: $ORACLE_HOME/bin/oracle. Pgrep takes a string as an argument and returns the process ID’s where the program name matches that string. Both ps tasks are better suited to the “pgrep” utility. Now, typically what we are trying to do is check for the existence of a process, or get its process ID. The best part is that while the grep command line still has the brackets, grep itself strips them away and treats it as a single character, so we don’t match our own command line. We only put one character in the set, so “” is the equivalent of searching for just “p”. Grep sees the characters in brackets as a set and matches any of the characters you provide. The simplest way is to put the first character of the search pattern in brackets: ps -ef|grep mon $ ps -ef|grep mon A better way is to use a regular expression with grep to keep it from matching itself. However, this starts another process, and takes time and resources. This excludes the grep command itself from the search. ![]() So, one thing you commonly see in a shell script to check for a process is “ps -ef|grep pmon|grep -v grep”. This is because the “pmon” argument to grep shows up on the command line. One of the problems in using “ps -ef|grep pmon” to look for the pmon process, for example, is that you also see the grep command itself: $ ps -ef|grep pmon oraclexe 6179 1 0 20:00 ? 00:00:00 ora _ xe _ pmon _ XE The “-e” option lists all processes running on the system, and “-f” give a “full” listing, which lists more columns of information, such at process start time, and the process ID of the parent process. ps -fu oracle), to look for a particular process by process ID (ps -fp PID), and to look for a process across the whole system (ps -ef|grep pmon). Some typical uses are to look at all processes for a user (e.g. Of course the most used utility by anyone is the “ps” command. In this brief article, I will talk about those I use nearly every day to work with Oracle systems. There are a great deal of useful tools and scripting languages, enough to fill several volumes. In this article I’m going to discuss some of my favorite utilities and show examples of how to use them. Regardless of your work environment, knowing how to troubleshoot from the Unix operating system can help you discover problems that you could not find just by looking in Oracle. In some companies, the Oracle DBA and the System Administrator are one and the same, and in others there are teams of both. Content has been updated where appropriate. David Woodard | Originally appeared in March 2006 Bricks newsletter.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |